﻿Option Strict On
Imports DevExpress.XtraNavBar
Imports System.Threading
Imports System.Threading.Tasks
Imports System.ComponentModel

Public Class FRM_00001
    'Set to 'Description for backward compatibility ... to be 'Caption' ....
    Public Property LocalizedBy As String = "Description"

    Public aculture As String = Thread.CurrentThread.CurrentCulture.DisplayName
    Private bw As System.ComponentModel.BackgroundWorker = New System.ComponentModel.BackgroundWorker
    Private waitWindow As DevExpress.Utils.WaitDialogForm

    Public WithEvents aTrayIcon As NotifyIcon

    Private aMDIHelper As MainMDIHelper

    Public Sub New()

        Dim aMetavalue As MetaValue

        AddHandler bw.DoWork, AddressOf ReadSecurityProfile
        AddHandler bw.RunWorkerCompleted, AddressOf ApplySecurityProfile

        'TestPoint: Depuis la version 11.2 les skin sont dans le DLL BonusSkins
        ' http://www.devexpress.com/Support/Center/p/B209399.aspx
        DevExpress.UserSkins.BonusSkins.Register()
        '    'This call is required by the Windows Form DesignerTimeSheet
        Try
            If Connection.Db IsNot Nothing Then

                aculture = AppManager.ApplicationOption.Culture
                Thread.CurrentThread.CurrentCulture = New CultureInfo(aculture)
                Thread.CurrentThread.CurrentUICulture = New CultureInfo(aculture)

                aMetavalue = MetaValue.GetMetaValueByCode("LocalizedBy")
                If aMetavalue IsNot Nothing Then
                    LocalizedBy = aMetavalue.Value
                End If
            End If

            'Nevron Licensing for Descktop redistribution this code MUST BE THERE .
            'Ref:  http://helpdotnetvision.nevron.com/Activation.html
            LoadnevronDevLicense()


        Catch ex As Exception
            ' C'est voulue on veut pas d'erreur comme ca LocalizedBy = Description
        Finally

            InitializeComponent()
            Me.BarStaticLocaliseBy.Caption = LocalizedBy
            BarStaticLang.Caption = aculture
            BarStaticConnection.Caption = "not Connected"

            ' Add any initialization after the InitializeComponent() call
            ' Me.New(Nothing)  aTrayIcon = New NotifyIcon()
            ' aTrayIcon.Icon = My.Resources.SystemBOX
            ' aTrayIcon.Visible = True
            ' aTrayIcon.Text = "SystemBOX Notification Area"
        End Try
    End Sub

    Private Sub SystemBoxMDIExp_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        'TODO HACK1: Loader la table de securité des menus. Pour cacher les groupes ou disabler les menus. GO DAVID - AL 2011-10-21
        ' 1- For each des group menu a cacher
        ' 2- For each des menu a disabler

        Try
            'By design we put in a Try Catch - aleblanc 2012-02-20
            Me.Text = AppManager.ApplicationOption.ApplicationTitle
        Catch ex As Exception
            'BUGBUG :do not use ex message, this will make the app to fail... yet not explained B.D 2014-08-26
            BarStaticConnection.Caption = "Check default connection"
            Me.Text = "SystemBox Express"
        End Try

        Dim MenuItem As NavBarItem
        Dim MenuGroup As NavBarGroup
        For Each MenuItem In Me.PluginNavigator.Items
            MenuItem.Enabled = False
            MenuItem.Visible = False
        Next

        For Each MenuGroup In Me.PluginNavigator.Groups
            MenuGroup.Visible = False
        Next

        aMDIHelper = New MainMDIHelper(Me, DockManager1, XtraTabbedMdiManager1)

        Dim apath As String = IO.Path.GetDirectoryName(Application.ExecutablePath)
        Dim openOfficeDictionary As New DevExpress.XtraSpellChecker.SpellCheckerOpenOfficeDictionary()
        SharedDictionaryStorage1.Dictionaries.Clear()

        openOfficeDictionary.DictionaryPath = apath & "\Dictionaries\en_US\en_US.dic"
        openOfficeDictionary.GrammarPath = apath & "\Dictionaries\en_US\en_US.aff"
        openOfficeDictionary.Culture = New System.Globalization.CultureInfo("en-US")
        openOfficeDictionary.Load()
        SharedDictionaryStorage1.Dictionaries.Add(openOfficeDictionary)


        openOfficeDictionary.DictionaryPath = apath & "\Dictionaries\fr-CA\fr-toutesvariantes.dic"
        openOfficeDictionary.GrammarPath = apath & "\Dictionaries\fr-CA\fr-toutesvariantes.aff"
        openOfficeDictionary.Culture = New System.Globalization.CultureInfo("fr-CA")
        openOfficeDictionary.Load()
        SharedDictionaryStorage1.Dictionaries.Add(openOfficeDictionary)
    End Sub


#Region "General FRM_00001"


    ''' <summary>
    ''' SetRibbonSecurity()
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub SetRibbonSecurity()
        Dim aControlprops As DataView
        Dim aRibbonPage As XtraBars.Ribbon.RibbonPage
        Dim aRibbonPageGrp As XtraBars.Ribbon.RibbonPageGroup
        Dim aRibbonItem As XtraBars.BarItem

        'Set Security and Multi-Language for Ribbon Pages and Page's Groups
        For Each aRibbonPage In RibbonControl1.Pages
            aControlprops = (From oControl In AppManager.DataSubjectAccess.AsEnumerable() _
                 Where oControl.Field(Of String)("ControlCD") = aRibbonPage.Name _
                 And oControl.Field(Of String)("Property") = "Visible" _
                Select oControl).AsDataView()

            If aControlprops.Count = 0 Then
                'outstanding  issue : it should be normaly False , but until backward compatibility is cvompleted we accept 'True'
                aRibbonPage.Visible = True
            Else
                aRibbonPage.Visible = CBool(aControlprops.Item(0).Row("Value"))
                Select Case LocalizedBy
                    Case "Caption"
                        aControlprops = (From oControl In AppManager.DataSubjectAccess.AsEnumerable() _
                                   Where oControl.Field(Of String)("ControlCD") = aRibbonPage.Name _
                                     And oControl.Field(Of String)("Property") = "Text" _
                                  Select oControl).AsDataView()
                        If aControlprops.Count = 1 Then
                            ''Debug
                            'Console.WriteLine(aControlprops.Item(0).Row("PropertyString").ToString())
                            aRibbonPage.Text = aControlprops.Item(0).Row("PropertyString").ToString()
                        End If
                    Case Else
                        If AppManager.ApplicationOption.DescriptionColumnIndex = 2 Then
                            aRibbonPage.Text = aControlprops.Item(0).Row("ControlDescr_PRM").ToString()
                        ElseIf AppManager.ApplicationOption.DescriptionColumnIndex = 3 Then
                            aRibbonPage.Text = aControlprops.Item(0).Row("ControlDescr_ALT").ToString()
                        End If
                End Select
            End If


            'Set Security and Multi-Language for Ribbon Page's Groups
            For Each aRibbonPageGrp In aRibbonPage.Groups
                aControlprops = (From oControl In AppManager.DataSubjectAccess.AsEnumerable() _
                    Where oControl.Field(Of String)("ControlCD") = aRibbonPageGrp.Name _
                                 And oControl.Field(Of String)("Property") = "Visible" _
                Select oControl).AsDataView()

                If aControlprops.Count = 0 Then
                    aRibbonPage.Visible = True
                Else
                    aRibbonPageGrp.Visible = CBool(aControlprops.Item(0).Row("Value"))
                    Select Case LocalizedBy
                        Case "Caption"
                            aControlprops = (From oControl In AppManager.DataSubjectAccess.AsEnumerable() _
                                       Where oControl.Field(Of String)("ControlCD") = aRibbonPageGrp.Name _
                                         And oControl.Field(Of String)("Property") = "Text" _
                                      Select oControl).AsDataView()
                            If aControlprops.Count = 1 Then
                                ''Debug
                                'Console.WriteLine(aControlprops.Item(0).Row("PropertyString").ToString())
                                aRibbonPageGrp.Text = aControlprops.Item(0).Row("PropertyString").ToString()
                            End If
                        Case Else
                            If AppManager.ApplicationOption.DescriptionColumnIndex = 2 Then
                                aRibbonPageGrp.Text = aControlprops.Item(0).Row("ControlDescr_PRM").ToString()
                            ElseIf AppManager.ApplicationOption.DescriptionColumnIndex = 3 Then
                                aRibbonPageGrp.Text = aControlprops.Item(0).Row("ControlDescr_ALT").ToString()
                            End If

                    End Select

                End If
            Next
        Next

        'Set Security and Multi-Language for Ribbon Items
        For Each aRibbonItem In RibbonControl1.Items
            aControlprops = (From oControl In AppManager.DataSubjectAccess.AsEnumerable() _
                         Where oControl.Field(Of String)("ControlCD") = aRibbonItem.Name _
                                 And oControl.Field(Of String)("Property") = "Visible" _
                Select oControl).AsDataView()

            If aControlprops.Count = 0 Then
                'outstanding  issue : it should be normaly False , but until backward compatibility is cvompleted we accept 'True'
                aRibbonItem.Visibility = XtraBars.BarItemVisibility.Always
                'XtraBars.BarItemVisibility.Always()
                'aRibbonItem.Visibility = CType(0, XtraBars.BarItemVisibility)
            Else
                aRibbonItem.Visibility = GetBarItemVisibility(aControlprops.Item(0).Row("Value").ToString)
                Select Case LocalizedBy
                    Case "Caption"
                        aControlprops = (From oControl In AppManager.DataSubjectAccess.AsEnumerable() _
                                   Where oControl.Field(Of String)("ControlCD") = aRibbonItem.Name _
                                     And oControl.Field(Of String)("Property") = "Caption" _
                                  Select oControl).AsDataView()
                        If aControlprops.Count = 1 Then
                            ''Debug
                            ' Console.WriteLine(aControlprops.Item(0).Row("PropertyString").ToString())
                            aRibbonItem.Caption = aControlprops.Item(0).Row("PropertyString").ToString()

                        End If
                    Case Else
                        If AppManager.ApplicationOption.DescriptionColumnIndex = 2 Then
                            aRibbonItem.Caption = aControlprops.Item(0).Row("ControlDescr_PRM").ToString()
                        ElseIf AppManager.ApplicationOption.DescriptionColumnIndex = 3 Then
                            aRibbonItem.Caption = aControlprops.Item(0).Row("ControlDescr_ALT").ToString()
                        End If

                End Select

            End If

        Next
    End Sub



    ''' <summary>
    ''' Reload active Controls with is appropriate child grid 
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub ReloadActiveGrid()
        CollectMemory()
        Dim iReloadPanel As IReloadCommand = Nothing
        Dim iReloadMDIfrm As IReloadCommand = Nothing
        Dim aDockPanel As DockPanel = Nothing

        'Le Focus est tu sur un Explorer ?
        If TypeOf Me.ActiveControl Is DockPanel Then
            iReloadPanel = TryCast(CType(Me.ActiveControl, DockPanel).ActiveControl, IReloadCommand)
        End If

        ' on cherche les Controls qui ont Ireloadcommand
        If Not Me.ActiveMdiChild Is Nothing Then
            If TypeOf Me.ActiveMdiChild Is IReloadCommand Then
                iReloadMDIfrm = TryCast(Me.ActiveMdiChild, IReloadCommand)
            ElseIf Me.ActiveMdiChild.Controls.Count > 0 AndAlso TypeOf Me.ActiveMdiChild.Controls(0) Is IReloadCommand Then
                iReloadMDIfrm = TryCast(Me.ActiveMdiChild.Controls(0), IReloadCommand)
            End If
        End If
        '
        Try
            'Est-ce que je peux retrouver l'explorer de la Grille ?
            If iReloadMDIfrm IsNot Nothing Then
                aDockPanel = DockManager1.Panels.Item(iReloadMDIfrm.CtrlName)
                iReloadPanel = TryCast(aDockPanel.ControlContainer.Controls.Item(0), IReloadCommand)
                If iReloadPanel Is Nothing Then
                    iReloadPanel = TryCast(aDockPanel, IReloadCommand)
                End If
            End If
        Catch
            'C'est voulu pas de code aleblanc - 2012-05-09
            'La ligne DockManager1.Panels.Item(iReloadMDIfrm.CtrlName) peut planter, si l'item existe pas.
        End Try

        'J'ai retrouver la grille et sont Explorer
        If iReloadMDIfrm IsNot Nothing AndAlso iReloadPanel IsNot Nothing Then
            If iReloadMDIfrm.CtrlName = iReloadPanel.CtrlName Then
                Cache.CacheExt.ClearCache()
                iReloadMDIfrm.ReloadCommand()
                iReloadPanel.ReloadCommand()
            End If
        ElseIf iReloadMDIfrm IsNot Nothing Then
            'J'ai retrouver la grille seulement
            Cache.CacheExt.ClearCache()
            iReloadMDIfrm.ReloadCommand()
        ElseIf iReloadPanel IsNot Nothing Then
            'J'ai juste un Explorer
            iReloadPanel.ReloadCommand()
        End If
    End Sub


    ''' <summary>
    ''' SSPP: Use this Subroutine to close all MDI child
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks>All the dispose call is to recover memory</remarks>
    Private Sub MDIForm_Closing(sender As Object, e As FormClosingEventArgs)
        Dim form As XtraForm = CType(sender, XtraForm)
        Dim panel As DockPanel = DockManager1.Panels(CType(sender, Form).Name)
        Dim dispo As IDisposable

        Dim iSave As ISaveCommand

        ''TestPoint: By design we call dispose on each control that have the dispose Method
        For Each o As Object In form.Controls

            iSave = TryCast(o, ISaveCommand)
            If iSave IsNot Nothing AndAlso iSave.Dataset.HasChanges Then
                If MsgBox(String.Format("Vous avez des modification qui n'ont pas été sauvegarder !{0}Voulez-vous les sauvegarder maintenant ?", vbCrLf), MsgBoxStyle.YesNo, "* ATTENTION *") = Windows.Forms.DialogResult.Yes Then
                    iSave.SaveCommand()
                End If
            End If
            '
            dispo = TryCast(o, IDisposable)
            If dispo IsNot Nothing Then
                dispo.Dispose()
            End If
        Next

        If panel IsNot Nothing Then
            For Each o As Object In panel.Controls
                dispo = TryCast(o, IDisposable)
                If dispo IsNot Nothing Then
                    dispo.Dispose()
                End If
            Next
            DockManager1.RemovePanel(panel)
            panel.Controls.Clear()
            panel.Dispose()
        End If

        RemoveHandler form.FormClosing, AddressOf MDIForm_Closing
        form.Controls.Clear()
        form.Dispose()
        form = Nothing
        panel = Nothing

        If XtraTabbedMdiManager1.Pages.Count = 0 Then
            Cache.CacheExt.ClearCache()

            GC.Collect()
            GC.WaitForFullGCComplete()

        End If
    End Sub

    Private Sub FRM_00001_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
        Me.Dispose()
    End Sub


    ''' <summary>
    ''' Pour recupérer de la mémoire
    ''' On l'appel a plusieurs fois car le GC semble prendre du temps avant de récupérer la mémoire... aleblanc 2011-06-08
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub CollectMemory()
        GC.Collect()
        GC.WaitForPendingFinalizers()
    End Sub

    Public Sub LoadLoginForm()
        CollectMemory()
        Using auth As WinFormExt.LoginWindow = New WinFormExt.LoginWindow()
            If (auth.ShowDialog() = DialogResult.OK) Then
                BarStaticConnection.Caption = String.Format("{0}\{1}  {2}", AppManager.DbServerName, AppManager.DbName, AppManager.UserName)
                BarStaticLang.Caption = AppManager.ApplicationOption.Culture
                waitWindow = New DevExpress.Utils.WaitDialogForm(DeskTopManager.GetMessage("MES-000009"), DeskTopManager.GetMessage("MES-000010"))  '"Un Instant svp""Chargement de votre profile ..."
                waitWindow.LookAndFeel.SkinName = "Blue"
                waitWindow.LookAndFeel.Style = DevExpress.LookAndFeel.LookAndFeelStyle.Skin
                waitWindow.LookAndFeel.UseDefaultLookAndFeel = False
                waitWindow.LookAndFeel.UseWindowsXPTheme = False

                'voir sub New ; AddHandler bw.DoWork, AddressOf ReadSecurityProfile
                bw.RunWorkerAsync()
                auth.Close()
            End If
        End Using
    End Sub

    ''' <summary>
    ''' Use to map values from Meta to the equivalent of XtraBars.BarItemVisibility
    ''' </summary>
    ''' <param name="value"></param>
    ''' <returns></returns>
    ''' <remarks> Always like this at SCIEF
    '''           0 = Not Visible / False
    '''           1 = Visible / True
    ''' </remarks>
    Private Function GetBarItemVisibility(ByVal value As String) As XtraBars.BarItemVisibility
        Dim result As XtraBars.BarItemVisibility
        Select Case value
            Case "0" ' False
                result = XtraBars.BarItemVisibility.Never
            Case "1" ' True
                result = XtraBars.BarItemVisibility.Always
            Case "2"
                result = XtraBars.BarItemVisibility.OnlyInCustomizing
            Case "3"
                result = XtraBars.BarItemVisibility.OnlyInRuntime
            Case "4"
            Case Else
                result = XtraBars.BarItemVisibility.Never
        End Select
        Return result
    End Function

    Private Function FormIsOpen(ByVal frmName As String) As Boolean
        For Each aFrm As Form In Me.MdiChildren
            If aFrm.Name = frmName Then
                Return True
            End If
        Next

        Return False
    End Function

    ''' <summary>
    '''  This is where we read the metaData of Metacontrol and MetaUserControlprops
    ''' to set Module security
    ''' Also you can use the DEBUG statement to view the Metacontrols that are in DataBase but no more assign in Designer.
    ''' Refer : AuditNoMenuitemExist
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub ApplySecurityProfile(ByVal sender As Object, ByVal e As RunWorkerCompletedEventArgs)
        Dim MenuItem As NavBarItem
        Dim MenuGroup As NavBarGroup
        Dim aControlprops As DataView

        'Hack: Maintenant que nous somme connecter on prend les option du users
        AppManager.ApplicationOption = Nothing
        '
        AppManager.DataSubjectAccess = SecurityProfiler_PL.SecurityProfileDS.Tables("DataSubjectSecurity")
        If AppManager.DataSubjectAccess.Rows.Count = 0 Then
            Return
        End If


        For Each MenuGroup In Me.PluginNavigator.Groups
            aControlprops = (From oControl In AppManager.DataSubjectAccess.AsEnumerable() _
                       Where oControl.Field(Of String)("ControlCD") = MenuGroup.Name _
                         And oControl.Field(Of String)("Property") = "Visible" _
                         And oControl.Field(Of String)("VALUE") = "1"
                      Select oControl).AsDataView()
            If aControlprops.Count = 0 Then
                MenuGroup.Visible = False
            Else
                MenuGroup.Visible = CBool(aControlprops.Item(0).Row("Value"))
                MenuGroup.Tag = aControlprops.Item(0).Row("ControlID")

                Select Case LocalizedBy
                    Case "Caption"
                        aControlprops = (From oControl In AppManager.DataSubjectAccess.AsEnumerable() _
                                   Where oControl.Field(Of String)("ControlCD") = MenuGroup.Name _
                                     And oControl.Field(Of String)("Property") = "Caption" _
                                  Select oControl).AsDataView()
                        If aControlprops.Count = 1 Then
                            MenuGroup.Caption = aControlprops.Item(0).Row("PropertyString").ToString()
                        End If
                    Case Else
                        If AppManager.ApplicationOption.DescriptionColumnIndex = 2 Then
                            MenuGroup.Caption = aControlprops.Item(0).Row("ControlDescr_PRM").ToString()
                        ElseIf AppManager.ApplicationOption.DescriptionColumnIndex = 3 Then
                            MenuGroup.Caption = aControlprops.Item(0).Row("ControlDescr_ALT").ToString()
                        End If
                End Select


                ''Debug : Show the Group menu
                'Console.WriteLine(String.Format("Name : {0} , Caption : {1}, Tag : {2}", MenuGroup.Name, MenuGroup.Caption, MenuGroup.Tag.ToString()))

                'we have a dataView containning all control of Parent Control

                ' aParentID = CType(MenuGroup.Tag, Guid?)

                Try
                    aControlprops = (From oControl In AppManager.DataSubjectAccess.AsEnumerable() _
                                        Order By oControl.Field(Of Integer)("ArrayIndex")
                                        Where oControl.Field(Of Guid?)("ParentControlId_FK") = CType(MenuGroup.Tag, Guid?) _
                                        And oControl.Field(Of String)("Property") = "Visible" _
                                        And oControl.Field(Of String)("VALUE") = "1" _
                                        Select oControl).AsDataView()

                Catch ex As Exception
                    MessageWindow.ShowMessage(ex.Message, MsgBoxStyle.Information)




                End Try
                MenuGroup.ItemLinks.Clear()
                'we will go throught the dataview to add or remove
                If aControlprops.Count > 0 Then
                    For Each arow As DataRowView In aControlprops
                        MenuItem = Me.PluginNavigator.Items(arow("ControlCD").ToString)
                        If MenuItem IsNot Nothing Then
                            MenuItem.Visible = CBool(arow("VALUE").ToString)
                            If MenuItem.Visible Then
                                'we belive that we must set the propertie before assign the itemLink
                                'a) Assign the Enabled Prop
                                aControlprops = (From oControl In AppManager.DataSubjectAccess.AsEnumerable() _
                                                           Where oControl.Field(Of String)("ControlCD") = MenuItem.Name _
                                                             And oControl.Field(Of String)("Property") = "Enabled"
                                                            Select oControl).AsDataView()
                                If aControlprops.Count = 0 Then
                                    MenuItem.Enabled = False
                                Else
                                    MenuItem.Enabled = CBool(aControlprops.Item(0).Row("Value"))
                                End If
                                'b) assign the Caption based on Caption
                                Select Case LocalizedBy
                                    Case "Caption"
                                        aControlprops = (From oControl In AppManager.DataSubjectAccess.AsEnumerable() _
                                                       Where oControl.Field(Of String)("ControlCD") = MenuItem.Name _
                                                         And oControl.Field(Of String)("Property") = "Caption" _
                                                      Select oControl).AsDataView()
                                        If aControlprops.Count = 1 Then
                                            ''Debug
                                            'Console.WriteLine(aControlprops.Item(0).Row("PropertyString").ToString())
                                            MenuItem.Caption = aControlprops.Item(0).Row("PropertyString").ToString()


                                        End If
                                    Case Else
                                        If AppManager.ApplicationOption.DescriptionColumnIndex = 2 Then
                                            MenuItem.Caption = aControlprops.Item(0).Row("ControlDescr_PRM").ToString()
                                        ElseIf AppManager.ApplicationOption.DescriptionColumnIndex = 3 Then
                                            MenuItem.Caption = aControlprops.Item(0).Row("ControlDescr_ALT").ToString()
                                        End If

                                End Select

                                MenuGroup.ItemLinks.Add(MenuItem)
                            Else
                                MenuGroup.ItemLinks.Remove(MenuItem)
                            End If
                        Else
                            ''AuditNoMenuitemExist
                            Console.WriteLine(String.Format(" Menuitem is not in designer, MetaControl = {0}", arow("ControlCD").ToString))
                        End If
                    Next
                End If
            End If
        Next



        SetRibbonSecurity()
        DeskTopManager.GetSecurityProfile()
        AppOption.GetSeparator()
        AppOption.GetSociety()
        ''TestPoint
        ' Console.WriteLine(New AppOption().Culture)
        waitWindow.Close()
    End Sub


    Private Sub ReadSecurityProfile(ByVal sender As Object, ByVal e As DoWorkEventArgs)
        Try
            'Force Delete Security Files
            Dim mq As MetaQuery = MetaQuery.GetMetaQueryByName("LocalOption")
            mq.SQLWhere = String.Format("MetaUserOptions.UserId_FK = '{0}' AND MetaUserOptions.AppOptionId_FK = '{1}'", SCIEF.ActiveFramework.CommonExt.Base.AppManager.UserID, "0B4DE1BF-B3F9-4EB0-B6A5-2EEF7BB6134A")
            mq.FillResultQuery(CommandBehavior.CloseConnection)
            If mq.ResultQuery.Rows.Count = 1 AndAlso CBool(mq.ResultQuery.Rows(0)("OptionValue").ToString) Then
                If System.IO.Directory.GetFiles(DeskTopManager.ApplicationDataFolder, "*.stbx").Length > 0 Then
                    For Each FileFound As String In System.IO.Directory.GetFiles(DeskTopManager.ApplicationDataFolder, "*.stbx")
                        System.IO.File.Delete(FileFound)
                    Next
                End If

                'Reset(OptionValue = 0) Option ForceDelete
            End If

        Catch ex As Exception
        End Try


        If Not System.IO.File.Exists(DeskTopManager.SecurityFileNameDataFieldSecurity) OrElse _
           Not System.IO.File.Exists(DeskTopManager.SecurityFileNameDataSubjectSecurity) OrElse _
           Not System.IO.File.Exists(DeskTopManager.SecurityFileNameSiteSecurity) OrElse _
           Not System.IO.File.Exists(DeskTopManager.SecurityFileNameSocietySecurity) OrElse _
           Not System.IO.File.Exists(DeskTopManager.SecurityFileNameUserColumnSecurity) Then
            SystemBoxSDK.PL.MetaSDK.SecurityProfiler_PL.GenerateAllSecurity(AppManager.UserID, AppManager.ApplicationOption.LanguageId)
            SystemBoxSDK.PL.MetaSDK.SecurityProfiler_PL.WriteSecurityProfile(DeskTopManager.SecurityFileNameUserColumnSecurity, DeskTopManager.SecurityFileNameDataFieldSecurity, DeskTopManager.SecurityFileNameDataSubjectSecurity, DeskTopManager.SecurityFileNameSiteSecurity, DeskTopManager.SecurityFileNameSocietySecurity, DeskTopManager.SecurityFileNameGroupListSecurity)
        Else
            SecurityProfiler_PL.SecurityProfileDS = New DataSet("SecurityProfile")
            SecurityProfiler_PL.ReadDataSubjectSecurity(DeskTopManager.SecurityFileNameDataSubjectSecurity)
            SecurityProfiler_PL.ReadGroupListSecurity(DeskTopManager.SecurityFileNameGroupListSecurity)
            SecurityProfiler_PL.ReadUserColumnSecurity(DeskTopManager.SecurityFileNameUserColumnSecurity)
            SecurityProfiler_PL.ReadDataFieldSecurity(DeskTopManager.SecurityFileNameDataFieldSecurity)
            SecurityProfiler_PL.ReadSiteSecurity(DeskTopManager.SecurityFileNameSiteSecurity)
            SecurityProfiler_PL.ReadSocietySecurity(DeskTopManager.SecurityFileNameSocietySecurity)
        End If
    End Sub


    Private Sub FRM_00001_FormClosed(sender As Object, e As FormClosedEventArgs) Handles Me.FormClosed
        ''Si l'application plante, l'icon reste dans le Tray
        'aTrayIcon.Visible = False
        'aTrayIcon.Dispose()
    End Sub


    Private Sub aTrayIcon_MouseClick(sender As Object, e As MouseEventArgs) Handles aTrayIcon.MouseClick
        If e.Button = MouseButtons.Right Then
            MessageWindow.ShowMessage("In developpement....", MsgBoxStyle.Information)
        End If
    End Sub

    Public Overridable Sub LoadnevronDevLicense()
        Dim license As New NLicense("0b163666-1c00-a001-1502-1e6fab020803")
        NLicenseManager.Instance.SetLicense(license)
        NLicenseManager.Instance.LockLicense = True
    End Sub

#End Region

#Region "Ribbon Menu"
    '

    ''' <summary>
    ''' BBTN_00001 / Connect : This sub open connection's form
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub BBTN_00001_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles BBTN_00001.ItemDoubleClick, BBTN_00001.ItemClick
        LoadLoginForm()
    End Sub

    ''' <summary>
    ''' BBTN_00002 / Local Option : This sub opens the Local Options form.
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub BBTN_00002_LocalOption(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles BBTN_00002.ItemClick, BBTN_00002.ItemDoubleClick
        Try
            If SCIEF.ActiveFramework.CommonExt.Base.AppManager.IsConnected Then
                Me.Cursor = Cursors.WaitCursor
                Dim frm As AppOptionForm = New AppOptionForm()
                frm.ShowDialog()
                Me.Cursor = Cursors.Default
            Else
                If MessageWindow.ShowMessage(DeskTopManager.GetMessage("MES-000001")) = DialogResult.OK Then
                    LoadLoginForm()
                End If
            End If
        Catch ex As Exception
            Throw ex
        End Try


    End Sub

    ''' <summary>
    ''' BBTN_00003_Disconnect
    ''' This sub disconect the apllication from a database.
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub BBTN_00003_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles BBTN_00003.ItemDoubleClick, BBTN_00003.ItemClick
        Dim Menuitem As NavBarItem
        Dim Menugroup As NavBarGroup
        Dim pg As XtraTabbedMdi.XtraMdiTabPage
        Dim panel As DockPanel
        Dim panels As List(Of DockPanel) = New List(Of DockPanel)

        SCIEF.ActiveFramework.CommonExt.Base.AppManager.ClearContext()
        SCIEF.ActiveFramework.CommonExt.Base.Connection.CloseConnection()
        SCIEF.ActiveFramework.CommonExt.Base.AppManager.ResetCache()

        BarStaticConnection.Caption = "Not Connected" ' to localize with Metastring MetaString.GetMetaStringByCode(

        For Each Menuitem In Me.PluginNavigator.Items
            Menuitem.Enabled = False
            Menuitem.Visible = False
        Next

        For Each Menugroup In Me.PluginNavigator.Groups
            Menugroup.Visible = False
        Next

        While Me.XtraTabbedMdiManager1.Pages.Count > 0
            pg = Me.XtraTabbedMdiManager1.Pages(0)
            pg.MdiChild.Close()
        End While


        For Each panel In DockManager1.Panels
            If panel.Text <> "Modules" Then
                panels.Add(panel)
            End If
        Next

        For Each panel In panels
            DockManager1.RemovePanel(panel)
        Next

        CollectMemory()

    End Sub

    ''' <summary>
    ''' BBTN_00004 / Save : This sub saves data on the focused grid
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub BBTN_00004_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles BBTN_00004.ItemDoubleClick, BBTN_00004.ItemClick
        Dim iSaveCommand As ISaveCommand
        Me.Cursor = Cursors.WaitCursor
        'Applied Changes on grid
        If Not Me.ActiveMdiChild Is Nothing AndAlso Me.ActiveMdiChild.Controls.Count > 0 Then
            iSaveCommand = TryCast(Me.ActiveMdiChild.Controls(0), ISaveCommand)
            If iSaveCommand IsNot Nothing Then
                iSaveCommand.SaveCommand()
            End If
            'OutStandingIssue: Save doit retouner un ok... AL
        End If
        CollectMemory()
        Me.Cursor = Cursors.Default
    End Sub

    ''' <summary>
    ''' BBTN_00005 / New : This sub add a new row to the focused grid.
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub BBTN_00005_ItemClick(sender As System.Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BBTN_00005.ItemClick, BBTN_00005.ItemDoubleClick
        Dim iNewCommand As INewCommand
        Me.Cursor = Cursors.WaitCursor
        If Not Me.ActiveMdiChild Is Nothing AndAlso Me.ActiveMdiChild.Controls.Count > 0 Then
            iNewCommand = TryCast(Me.ActiveMdiChild.Controls(0), INewCommand)
            If iNewCommand IsNot Nothing Then
                iNewCommand.NewCommand()
            End If
        End If
        CollectMemory()
        Me.Cursor = Cursors.Default
    End Sub

    ''' <summary>
    ''' BBTN_00006 / Reload : This sub reload data on the focused grid.
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub BBTN_00006_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles BBTN_00006.ItemClick, BBTN_00006.ItemDoubleClick
        Me.Cursor = Cursors.WaitCursor
        ReloadActiveGrid()
        Me.Cursor = Cursors.Default
    End Sub

    ''' <summary>
    ''' BBTN_00008_PivotFieldList
    ''' This sub shows the Pivot Fields panel.
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub BBTN_00008_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles BBTN_00008.ItemClick, BBTN_00008.ItemDoubleClick
        If Not Me.MdiChildren.Length.Equals(0) Then
            If TypeOf (Me.ActiveMdiChild.Controls(0)) Is PivotExt Then

                Dim aForm As XtraEditors.XtraForm = CType(Me.ActiveMdiChild, XtraForm)
                Dim aModule As PivotExt = CType(aForm.Controls(0), PivotExt)

                aModule.PivotGridControl1.FieldsCustomization(FieldDockPanel)
            End If
        End If


        Dim adockpanel As XtraBars.Docking.DockPanel = New DevExpress.XtraBars.Docking.DockPanel() With {.Visibility = XtraBars.Docking.DockVisibility.AutoHide, .Text = "Fields"}
        adockpanel = Me.FieldDockPanel

        If adockpanel.Visibility = XtraBars.Docking.DockVisibility.AutoHide Then
            adockpanel.Visibility = XtraBars.Docking.DockVisibility.Hidden
        Else
            adockpanel.Visibility = XtraBars.Docking.DockVisibility.AutoHide
        End If
        CollectMemory()
    End Sub

    ''' <summary>
    ''' BBTN_00009 / Modules : This sub hide or show the left menu panel
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub BBTN_00009_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles BBTN_00009.ItemClick, BBTN_00009.ItemDoubleClick
        Dim adockpanel As XtraBars.Docking.DockPanel = New DevExpress.XtraBars.Docking.DockPanel() With {.Visibility = XtraBars.Docking.DockVisibility.AutoHide, .Text = "Moduless"}
        adockpanel = Me.ModulesDockPanel
        If adockpanel.Visibility = XtraBars.Docking.DockVisibility.AutoHide Then
            adockpanel.Visibility = XtraBars.Docking.DockVisibility.Hidden
        Else
            adockpanel.Visibility = XtraBars.Docking.DockVisibility.AutoHide
        End If
        CollectMemory()
    End Sub

    ''' <summary>
    ''' BBTN_00011 / ByPass Connection : This sub opens the ByPass Connection form.
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub BBTN_00011_ItemClick(sender As System.Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BBTN_00011.ItemClick, BBTN_00011.ItemDoubleClick

        '  Try
        ' If SCIEF.ActiveFramework.CommonExt.Base.AppManager.IsConnected Then  
        Me.Cursor = Cursors.WaitCursor
        Dim frm As ConnectionByPassForm = New ConnectionByPassForm()
        frm.ShowDialog()
        Me.Cursor = Cursors.Default
        'End if
        ' Catch ex As Exception
        'Throw ex
        'If MessageWindow.ShowMessage(DeskTopManager.GetMessage("MES-000001")) = DialogResult.OK Then
        '    LoadLoginForm()
        'End If
        'End Try


    End Sub

    ''' <summary>
    ''' BBTN_00013 / Mind Manager Help : 
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub BBTN_00013_ItemClick(sender As System.Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BBTN_00013.ItemClick, BBTN_00013.ItemDoubleClick
        Help.ShowHelp(Me, "Help.chm", HelpNavigator.TableOfContents, Nothing)
    End Sub

    ''' <summary>
    ''' BBTN_00014 / Keyboard Shortcuts : 
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub BBTN_00014_ItemClick(sender As System.Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BBTN_00014.ItemClick, BBTN_00014.ItemDoubleClick

        ' Just put the right TopicID when Ready : Bernard Desjardins

        Help.ShowHelp(Me, "Help.chm", HelpNavigator.TopicId, "9999")

    End Sub

    ''' <summary>
    ''' BBTN_00015 / System Info : 
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub BBTN_00015_ItemClick(sender As System.Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BBTN_00015.ItemClick, BBTN_00015.ItemDoubleClick

    End Sub

    ''' <summary>
    ''' BBTN_00016 / Register : 
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub BBTN_00016_ItemClick(sender As System.Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BBTN_00016.ItemClick, BBTN_00016.ItemDoubleClick
        Me.Cursor = Cursors.WaitCursor
        Dim SysBoxSvc As SystemBoxWSvc = New SystemBoxWSvc()
        Dim Msg As String = Nothing
        Try
            If SysBoxSvc.Register(System.Guid.NewGuid, Msg) Then
                MessageWindow.ShowMessage(Msg, MsgBoxStyle.Information)
            End If
        Catch ex As Exception
            MessageWindow.ShowMessage(ex.Message, MsgBoxStyle.Information)
        End Try
        Me.Cursor = Cursors.Default
    End Sub

    ''' <summary>
    ''' BBTN_00017 / License Key : 
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub BBTN_00017_ItemClick(sender As System.Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BBTN_00017.ItemClick, BBTN_00017.ItemDoubleClick
        Me.Cursor = Cursors.WaitCursor
        Dim SysBoxSvc As SystemBoxWSvc = New SystemBoxWSvc()
        Dim Msg As String = Nothing
        Try
            SysBoxSvc.ValidateLicense(System.Guid.NewGuid, Msg)
            MessageWindow.ShowMessage(Msg, MsgBoxStyle.Information)
        Catch ex As Exception
            MessageWindow.ShowMessage(ex.Message, MsgBoxStyle.Information)
        End Try
        Me.Cursor = Cursors.Default
    End Sub

    ''' <summary>
    ''' BBTN_00018 / Updates : 
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub BBTN_00018_ItemClick(sender As System.Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BBTN_00018.ItemClick, BBTN_00018.ItemDoubleClick

    End Sub

    ''' <summary>
    ''' BBTN_00019 (Delete Security Files)
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub BBTN_00019_ItemClick(sender As System.Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BBTN_00019.ItemClick
        If System.IO.Directory.GetFiles(DeskTopManager.ApplicationDataFolder, "*.stbx").Length > 0 Then
            For Each FileFound As String In System.IO.Directory.GetFiles(DeskTopManager.ApplicationDataFolder, "*.stbx")
                System.IO.File.Delete(FileFound)
            Next

            If System.IO.Directory.GetFiles(DeskTopManager.ApplicationDataFolder, "*.stbx").Length > 0 Then
                MessageWindow.ShowMessage("Security Files Always Exists", MsgBoxStyle.Exclamation)
            Else
                MessageWindow.ShowMessage("Security Files is Deleted", MsgBoxStyle.Information)
            End If
        End If
    End Sub

    ''' <summary>
    ''' BBTN_00020 / WebService
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub BBTN_00020_ItemClick(sender As System.Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BBTN_00020.ItemClick
        If SCIEF.ActiveFramework.CommonExt.Base.AppManager.IsConnected Then
            Me.Cursor = Cursors.WaitCursor
            Dim frm As WebService = New WebService()
            frm.ShowDialog()
            Me.Cursor = Cursors.Default
        Else
            If MessageWindow.ShowMessage(DeskTopManager.GetMessage("MES-000001")) = DialogResult.OK Then
                LoadLoginForm()
            End If
        End If
    End Sub

    ''' <summary>
    ''' BBTN_00021_
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub BBTN_00021_ItemClick(sender As Object, e As XtraBars.ItemClickEventArgs) Handles BBTN_00021.ItemClick

        CollectMemory()
        Me.Cursor = Cursors.WaitCursor


        Using auth As WinFormExt.ServerManagerForm = New WinFormExt.ServerManagerForm()
            If (auth.ShowDialog() = DialogResult.OK) Then
                BarStaticConnection.Caption = String.Format("{0}\{1}  {2}", AppManager.DbServerName, AppManager.DbName, AppManager.UserName)
                BarStaticLang.Caption = AppManager.ApplicationOption.Culture
                waitWindow = New DevExpress.Utils.WaitDialogForm(DeskTopManager.GetMessage("MES-000009"), DeskTopManager.GetMessage("MES-000010"))  '"Un Instant svp""Chargement de votre profile ..."
                waitWindow.LookAndFeel.SkinName = "Blue"
                waitWindow.LookAndFeel.Style = DevExpress.LookAndFeel.LookAndFeelStyle.Skin
                waitWindow.LookAndFeel.UseDefaultLookAndFeel = False
                waitWindow.LookAndFeel.UseWindowsXPTheme = False

                'voir sub New ; AddHandler bw.DoWork, AddressOf ReadSecurityProfile
                bw.RunWorkerAsync()
                auth.Close()
            End If
            Me.Cursor = Cursors.Default
        End Using
    End Sub

    ''' <summary>
    ''' BBTN_00022_
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub BBTN_00022_ItemClick(sender As Object, e As XtraBars.ItemClickEventArgs) Handles BBTN_00022.ItemClick
        Try

            Me.Cursor = Cursors.WaitCursor
            Dim newForm As XtraForm = New XtraForm() With {.Text = "Sql Backup", .Width = 800}
            Dim gridSP As GridExtSP = New GridExtSP("SSP_SQLBackup") With {.Dock = DockStyle.Fill}
            gridSP.SaveCMD = AddressOf aMDIHelper.CreateUser

            AddHandler gridSP.AfterLoad, AddressOf aMDIHelper.AddRowParameter

            newForm.Controls.Add(gridSP)
            newForm.ShowDialog()
            Me.Cursor = Cursors.Default
        Catch ex As Exception
            MessageWindow.ShowMessage(ex, MsgBoxStyle.Information)
        End Try
    End Sub


    ''' <summary>
    ''' FRM_????? (ViewHelp)
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00082_ItemClick(sender As System.Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles MNU_00082.ItemClick
        'MessageWindow.ShowMessage(DeskTopManager.GetMessage("UNDERCNST"))
        'MsgBox(System.IO.Path.Combine(Application.StartupPath, "Help.chm"))
        'Process.Start(System.IO.Path.Combine(Application.StartupPath, "Help.chm"))
        Help.ShowHelp(Me, "Help.chm", HelpNavigator.TableOfContents, Nothing)

    End Sub

    ''' <summary>
    ''' FRM_????? (About)
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00083_ItemClick(sender As System.Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles MNU_00083.ItemClick
        Dim splash As SplashScreen = New SplashScreen()
        splash.ControlBox = True
        'splash.Icon =   
        splash.Show(Me)
    End Sub

#End Region

#Region "Modules NavBar"
    ''SCIEF BP: Order by Alpha



    'If SCIEF.ActiveFramework.CommonExt.Base.AppManager.IsConnected Then
    '    Me.Cursor = Cursors.WaitCursor


    '    Me.Cursor = Cursors.Default
    'Else
    '    If MessageWindow.ShowMessage(DeskTopManager.GetMessage("MES-000001")) = DialogResult.OK Then
    '        LoadLoginForm()
    '    End If
    'End If

    'OutStandingIssue: A finir Aleblanc - 2011-08-12
    'Private Sub ProjectNavBar_LinkClicked_1(sender As System.Object, e As DevExpress.XtraNavBar.NavBarLinkEventArgs)
    '    'a) on check si on est connecter
    '    '   b.1) y faut passer une réference du PL à la GridExt ( pour que les events de la Gridext sache a qui retransmettre les events pour le processing)


    'Private Function ChangeLotStatus(ByVal aMetaDataTable As MetaDataTable) As Boolean
    '    Me.Cursor = Cursors.WaitCursor
    '    Dim SysBoxSvc As SystemBoxWSvc = New SystemBoxWSvc()
    '    Try
    '        Return SysBoxSvc.ChangeLotStatus(aMetaDataTable)
    '    Catch ex As Exception
    '        MessageWindow.ShowMessage(ex.Message, MsgBoxStyle.Information)
    '    End Try
    '    Me.Cursor = Cursors.Default
    '    Return False
    'End Function

#Region " Alpha "
    ''' <summary>
    ''' GPMN_00023
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>


    ''' <summary>
    ''' FRM_????? (MetaTest)
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks>Menu MetaTest</remarks>
    Private Sub MNU_00032_LinkClicked(ByVal sender As System.Object, ByVal e As NavBarLinkEventArgs) Handles MNU_00032.LinkClicked
        If SCIEF.ActiveFramework.CommonExt.Base.AppManager.IsConnected Then
            Me.Cursor = Cursors.WaitCursor

            Dim mds As MetaDataSet = New MetaDataSet()
            Dim grd As GridControl = New GridControl()

            mds.QueryName = "LotExpress"
            'mds.ControlID = Guid.Parse("42afd370-1a6f-4efe-82e7-7f3fb3b2a2b6")
            'mds.QueryID = Guid.Parse("ae399566-5a72-4b67-8ac7-0f0e0c05463a")
            mds.SQLWhere = String.Format("LotID = '{0}'", "cb8e0501-b7ee-47d1-989a-1cf24c7a19e0")
            mds.FillDataSetByQueryName()
            'mds.FillDataSetByControlID()
            'mds.FillDataSetByQueryID()
            '
            grd.DataSource = mds
            grd.DataMember = "LotExpress"
            '
            grd.Dock = DockStyle.Fill
            Dim newForm As XtraEditors.XtraForm = New XtraEditors.XtraForm() With {.Text = e.Link.Caption, .Icon = ImageExt.ToIcon(e.Link.GetImage(), 16, True), .ShowIcon = True}
            newForm.Controls.Add(grd)
            newForm.MdiParent = Me
            newForm.Show()

            Me.Cursor = Cursors.Default
        Else
            If MessageWindow.ShowMessage(DeskTopManager.GetMessage("MES-000001")) = DialogResult.OK Then
                LoadLoginForm()
            End If
        End If
    End Sub

    ''' <summary>
    ''' MNU_00033_GCCollect
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00033_GCCollect(ByVal sender As System.Object, ByVal e As NavBarLinkEventArgs) Handles MNU_00033.LinkClicked
        GC.Collect()
        GC.WaitForFullGCComplete()
        Cache.CacheExt.ClearCache()
    End Sub

    ''' <summary>
    ''' FRM????  Not Used
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00073_LinkClicked(sender As System.Object, e As DevExpress.XtraNavBar.NavBarLinkEventArgs) Handles MNU_00073.LinkClicked

    End Sub

    ''' <summary>
    ''' MNU_00087_ For New SO
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00087_LinkClicked(sender As Object, e As NavBarLinkEventArgs) Handles MNU_00087.LinkClicked

    End Sub

    ''' <summary>
    ''' MNU_0088_ For New PO
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_0088_LinkClicked(sender As System.Object, e As DevExpress.XtraNavBar.NavBarLinkEventArgs) Handles MNU_00088.LinkClicked

    End Sub

    ''' <summary>
    '''  LOTHierarchie
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00096_LinkClicked(sender As Object, e As NavBarLinkEventArgs) Handles MNU_00096.LinkClicked
        Const frmName As String = "FRM_000"

        If SCIEF.ActiveFramework.CommonExt.Base.AppManager.IsConnected Then
            Me.Cursor = Cursors.WaitCursor

            'J'ai tu le droit a cette fonction/Form

            If Not FormIsOpen(frmName) Then

                Dim adockpanel As XtraBars.Docking.DockPanel = DockManager1.AddPanel(XtraBars.Docking.DockingStyle.Left)
                adockpanel.FloatVertical = True
                adockpanel.Name = frmName
                adockpanel.Text = e.Link.Caption
                adockpanel.Width = 500 'looks good

                Dim DockImage As Image = CType(e.Link.GetImage().Clone, Image)
                DockImage.RotateFlip(RotateFlipType.Rotate270FlipNone)
                adockpanel.Image = DockImage

                adockpanel.Visibility = XtraBars.Docking.DockVisibility.AutoHide

                Dim aGridControlexp As LotHierarchieExplorer = New LotHierarchieExplorer("LotHierarchieRoot") With {.Dock = DockStyle.Fill, .PanelName = frmName, .PL = New PL.Void_PL("LotHierarchie")}
                aGridControlexp.KeyFieldName = "KeyID"
                aGridControlexp.ParentFieldName = "ParentID"

                adockpanel.ControlContainer.Controls.Add(aGridControlexp)

                Dim newForm As XtraEditors.XtraForm = New XtraEditors.XtraForm() With {.Name = frmName, .Text = e.Link.Caption, .Icon = ImageExt.ToIcon(e.Link.GetImage(), 16, True), .ShowIcon = True}
                AddHandler newForm.FormClosing, AddressOf MDIForm_Closing
                newForm.MdiParent = Me
            Else
                If DockManager1.Panels(frmName).Visibility = XtraBars.Docking.DockVisibility.Hidden Then
                    DockManager1.Panels(frmName).Visibility = XtraBars.Docking.DockVisibility.AutoHide
                End If
            End If

            Me.Cursor = Cursors.Default
        Else
            If MessageWindow.ShowMessage(DeskTopManager.GetMessage("MES-000001")) = DialogResult.OK Then
                LoadLoginForm()
            End If
        End If

    End Sub

    ''' <summary>
    ''' MNU_00098_ActivityCalendar
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00098_ActivityCalendar(sender As Object, e As NavBarLinkEventArgs) Handles MNU_00098.LinkClicked
        Const frmName As String = Nothing

        Me.Cursor = Cursors.WaitCursor
        'Howto: la propriété .FormCtrlCD  est l'interface avec lequel le GridExtPl obtient le CRUD security si le frmName est égal à un Metacontrol Name de Forme
        Dim pl As SystemBoxSDK.PL.Void_PL = New SystemBoxSDK.PL.Void_PL("ProjectActivityBy")
        Dim newForm As ActivitySchedulerControl = New ActivitySchedulerControl With {.Pl = pl, .FormName = frmName, .Name = frmName, .Text = e.Link.Caption, .Icon = ImageExt.ToIcon(e.Link.GetImage(), 16, True), .ShowIcon = True}
        AddHandler newForm.FormClosing, AddressOf MDIForm_Closing
        Me.Cursor = Cursors.Default
        newForm.MdiParent = Me

    End Sub


    ''' <summary>
    ''' Alpha - To be used for next alpha development
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00099_LinkClicked(sender As Object, e As NavBarLinkEventArgs) Handles MNU_00099.LinkClicked
        Const frmName As String = "Work Cell"


        If SCIEF.ActiveFramework.CommonExt.Base.AppManager.IsConnected Then
            Me.Cursor = Cursors.WaitCursor
            If Not FormIsOpen(frmName) Then

                Dim newForm As XtraEditors.XtraForm = New WorkCellExt With {.Name = frmName, .Text = e.Link.Caption, .Icon = ImageExt.ToIcon(e.Link.GetImage(), 16, True), .ShowIcon = True}
                newForm.MdiParent = Me

            End If

            Me.Cursor = Cursors.Default
        Else
            If MessageWindow.ShowMessage(DeskTopManager.GetMessage("MES-000001")) = DialogResult.OK Then
                LoadLoginForm()
            End If
        End If
        CollectMemory()
    End Sub

    ''' <summary>
    ''' MNU_00100_LinkClicked_ChartingROI
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00100_LinkClicked_ChartingROI(sender As Object, e As NavBarLinkEventArgs) Handles MNU_00100.LinkClicked
        Const frmName As String = "Charting ROI"


        If SCIEF.ActiveFramework.CommonExt.Base.AppManager.IsConnected Then
            Me.Cursor = Cursors.WaitCursor
            If Not FormIsOpen(frmName) Then

                Dim newForm As XtraEditors.XtraForm = New ChartingEXT With {.Name = frmName, .Text = e.Link.Caption, .Icon = ImageExt.ToIcon(e.Link.GetImage(), 16, True), .ShowIcon = True}
                newForm.MdiParent = Me

            End If

            Me.Cursor = Cursors.Default
        Else
            If MessageWindow.ShowMessage(DeskTopManager.GetMessage("MES-000001")) = DialogResult.OK Then
                LoadLoginForm()
            End If
        End If
        CollectMemory()
    End Sub

    ''' <summary>
    ''' MNU_00120_
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00120_LinkClicked(sender As Object, e As NavBarLinkEventArgs) Handles MNU_00120.LinkClicked
        Dim aWizard As PurgeTableWizardExt = New PurgeTableWizardExt
        aWizard.Show()
    End Sub


#End Region


#Region " MetaData "
    ''' <summary>
    ''' GPMNU_00023
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    ''' 


    ''' <summary>
    ''' MNU_00024_FRM_00024_MetaStrings
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00024_FRM_00024_MetaStrings(ByVal sender As System.Object, ByVal e As NavBarLinkEventArgs) Handles MNU_00024.LinkClicked
        aMDIHelper.MNU_FRM_LoadGrid("FRM_00024", e.Link.Caption, e.Link.GetImage(), PLTypeOf.MetaStrings_PL, "MetaStrings", AddressOf aMDIHelper.FRM_00024_Init_GridActionOptionList)
    End Sub

    ''' <summary>
    ''' MNU_00025_FRM_00026_MetaValues
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00025_FRM_00026_MetaValues(sender As System.Object, e As NavBarLinkEventArgs) Handles MNU_00025.LinkClicked
        aMDIHelper.MNU_FRM_LoadGrid("FRM_00026", e.Link.Caption, e.Link.GetImage(), PLTypeOf.MetaValues_PL, "MetaValues", AddressOf aMDIHelper.FRM_00026_Init_GridActionOptionList)

    End Sub

    ''' <summary>
    ''' MNU_00026_FRM_00022_MetaLayout
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00026_FRM_00022_MetaLayout(ByVal sender As System.Object, ByVal e As NavBarLinkEventArgs) Handles MNU_00026.LinkClicked
        aMDIHelper.MNU_FRM_LoadGrid("FRM_00022", e.Link.Caption, e.Link.GetImage(), PLTypeOf.Void_PL, "MetaLayouts")
    End Sub


    ''' <summary>
    ''' MNU_00027_FRM_00013_Command
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00027_FRM_00013_Command(ByVal sender As System.Object, ByVal e As NavBarLinkEventArgs) Handles MNU_00027.LinkClicked
        aMDIHelper.MNU_FRM_LoadExplorer("FRM_00013", e.Link.Caption, e.Link.GetImage, PLTypeOf.MetaCommand_PL, WinCtrlTypeOf.MetaCommandExplorer, "MetaCommandRoot")
    End Sub

    ''' <summary>
    ''' MNU_00028_FRM_00023_MetaLists
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00028_FRM_00023_MetaLists(ByVal sender As System.Object, ByVal e As NavBarLinkEventArgs) Handles MNU_00028.LinkClicked
        aMDIHelper.MNU_FRM_LoadGrid("FRM_00023", e.Link.Caption, e.Link.GetImage(), PLTypeOf.MetaLists_PL, "MetaLists", AddressOf aMDIHelper.FRM_00023_Init_GridActionOptionList)
    End Sub


    ''' <summary>
    ''' MNU_00029_FRM_00025_MetaTemplate
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00029_FRM_00025_MetaTemplate(ByVal sender As System.Object, ByVal e As NavBarLinkEventArgs) Handles MNU_00029.LinkClicked
        aMDIHelper.MNU_FRM_LoadGrid("FRM_00025", e.Link.Caption, e.Link.GetImage(), PLTypeOf.Void_PL, "MetaTemplates")
    End Sub

    ''' <summary>
    ''' MNU_00030_FRM_00015_MetaApplications
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00030_FRM_00015_MetaApplications(ByVal sender As System.Object, ByVal e As NavBarLinkEventArgs) Handles MNU_00030.LinkClicked
        aMDIHelper.MNU_FRM_LoadGrid("FRM_00015", e.Link.Caption, e.Link.GetImage(), PLTypeOf.MetaApplications_PL, "MetaApplications")
    End Sub

    ''' <summary>
    ''' MNU_00031_FRM_00021_MetaControls
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00031_FRM_00021_MetaControls(ByVal sender As System.Object, ByVal e As NavBarLinkEventArgs) Handles MNU_00031.LinkClicked
        aMDIHelper.MNU_FRM_LoadGrid("FRM_00021", e.Link.Caption, e.Link.GetImage(), PLTypeOf.MetaControls_PL, "MetaControls", AddressOf aMDIHelper.FRM_00021_Init_GridActionOptionList)
    End Sub


    ''' <summary>
    ''' MNU_00059_ImportMetaCommand
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00059_ExportMetaCommand(sender As System.Object, e As NavBarLinkEventArgs) Handles MNU_00059.LinkClicked
        MetaCommandExplorer.ImportCommand()
    End Sub

    ''' <summary>
    ''' MNU_00060_ImportMetaControls
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00060_ImportMetaControls(sender As System.Object, e As DevExpress.XtraNavBar.NavBarLinkEventArgs) Handles MNU_00060.LinkClicked
        aMDIHelper.ImportMetaControls()
    End Sub


    ''' <summary>
    ''' MNU_00102_FRM_00091_MetaSequence
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00102_FRM_00091_MetaSequence(sender As Object, e As NavBarLinkEventArgs) Handles MNU_00102.LinkClicked
        aMDIHelper.MNU_FRM_LoadGrid("FRM_00091", e.Link.Caption, e.Link.GetImage(), PLTypeOf.MetaSequence_PL, "MetaSequence", AddressOf aMDIHelper.FRM_00091_Init_GridActionOptionList)
    End Sub


    ''' <summary>
    ''' MNU_00112_AuditMaster
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00112_AuditMaster(sender As System.Object, e As NavBarLinkEventArgs) Handles MNU_00112.LinkClicked

    End Sub



#End Region

#Region " Security "
    ''' <summary>
    ''' GPMN_00012
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>


    ''' <summary>
    ''' GPMN_00012-Security  MNU_00106-SecurityReport  FRM_00078-SecurityReportForm
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00106_LinkPressed(sender As Object, e As NavBarLinkEventArgs) Handles MNU_00106.LinkPressed
        Const frmName As String = "FRM_00078"
        Dim adockpanel As XtraBars.Docking.DockPanel
        Dim aModule As ReportExplorer

        If SCIEF.ActiveFramework.CommonExt.Base.AppManager.IsConnected Then
            Me.Cursor = Cursors.WaitCursor

            If Not FormIsOpen(frmName) Then
                adockpanel = DockManager1.AddPanel(XtraBars.Docking.DockingStyle.Left)
                '
                'OUTSTANDINGISSUE: ramener le GroupMenu dans le constructeur au lieu de devoir se souvenir quil faut setter le Group. clieng 2013-04-19.
                aModule = New ReportExplorer("ReportRoot_MNU_00106") With {.Dock = DockStyle.Fill, .PL = Nothing, .PanelName = frmName, .GroupMenuID = IdRepository.GroupMenu.Item("GPMN_00012")}
                '
                adockpanel.FloatVertical = True
                adockpanel.Name = frmName
                adockpanel.Text = e.Link.Caption
                adockpanel.Width = 450
                adockpanel.Visibility = XtraBars.Docking.DockVisibility.Visible
                adockpanel.ControlContainer.Controls.Add(aModule)

                Dim DockImage As Image = CType(e.Link.GetImage().Clone, Image)
                DockImage.RotateFlip(RotateFlipType.Rotate270FlipNone)
                adockpanel.Image = DockImage

            Else
                If DockManager1.Panels(frmName).Visibility = XtraBars.Docking.DockVisibility.Hidden Then
                    DockManager1.Panels(frmName).Visibility = XtraBars.Docking.DockVisibility.AutoHide
                End If
            End If

            Me.Cursor = Cursors.Default
        Else
            '"Please Connect to a Database"
            If MessageWindow.ShowMessage(DeskTopManager.GetMessage("MES-000001")) = DialogResult.OK Then
                LoadLoginForm()
            End If
        End If
    End Sub


    ''' <summary>
    ''' MNU_00011_FRM_00043_RolesAndResponsabilities
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00011_FRM_00043_RolesAndResponsabilities(ByVal sender As System.Object, ByVal e As NavBarLinkEventArgs) Handles MNU_00011.LinkClicked
        aMDIHelper.MNU_FRM_LoadGrid("FRM_00043", e.Link.Caption, e.Link.GetImage(), PLTypeOf.MetaUsers_PL, "MetaUsers", AddressOf aMDIHelper.FRM_00043_Init_GridActionOptionList)
    End Sub

    ''' <summary>
    ''' FRM_00070(Site Access)
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00014_LinkClicked_FRM_00070_SiteAccess(sender As System.Object, e As NavBarLinkEventArgs) Handles MNU_00014.LinkClicked
        Const frmName As String = "SecuritySite"

        If SCIEF.ActiveFramework.CommonExt.Base.AppManager.IsConnected Then
            Me.Cursor = Cursors.WaitCursor

            If Not FormIsOpen(frmName) Then

                Dim adockpanel As XtraBars.Docking.DockPanel = DockManager1.AddPanel(XtraBars.Docking.DockingStyle.Left)
                adockpanel.FloatVertical = True
                adockpanel.Name = frmName
                adockpanel.Text = e.Link.Caption
                adockpanel.Width = 450
                adockpanel.Visibility = XtraBars.Docking.DockVisibility.AutoHide

                Dim DockImage As Image = CType(e.Link.GetImage().Clone, Image)
                DockImage.RotateFlip(RotateFlipType.Rotate270FlipNone)
                adockpanel.Image = DockImage


                Dim aModule As SecuritySiteControl = New SecuritySiteControl("SecuritySite") With {.Dock = DockStyle.Fill, .PanelName = frmName}
                aModule.KeyFieldName = "SiteId"
                aModule.ParentFieldName = "ParentSiteId_FK"
                adockpanel.ControlContainer.Controls.Add(aModule)
                Dim newForm As XtraEditors.XtraForm = New XtraEditors.XtraForm() With {.Name = frmName, .Text = e.Link.Caption, .Icon = ImageExt.ToIcon(e.Link.GetImage(), 16, True), .ShowIcon = True}
                AddHandler newForm.FormClosing, AddressOf MDIForm_Closing
                newForm.MdiParent = Me
            Else
                If DockManager1.Panels(frmName).Visibility = XtraBars.Docking.DockVisibility.Hidden Then
                    DockManager1.Panels(frmName).Visibility = XtraBars.Docking.DockVisibility.AutoHide
                End If
            End If

            Me.Cursor = Cursors.Default
        Else
            If MessageWindow.ShowMessage(DeskTopManager.GetMessage("MES-000001")) = DialogResult.OK Then
                LoadLoginForm()
            End If
        End If
    End Sub


    ''' <summary>
    ''' FRM_00071 (Society Acccess)
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00016_LinkClicked_FRM_00071_SocietyAccess(sender As System.Object, e As NavBarLinkEventArgs) Handles MNU_00016.LinkClicked
        Const frmName As String = "FRM_00071"

        If SCIEF.ActiveFramework.CommonExt.Base.AppManager.IsConnected Then
            Me.Cursor = Cursors.WaitCursor

            If Not FormIsOpen(frmName) Then

                Dim adockpanel As XtraBars.Docking.DockPanel = DockManager1.AddPanel(XtraBars.Docking.DockingStyle.Left)
                adockpanel.FloatVertical = True
                adockpanel.Name = frmName
                adockpanel.Text = e.Link.Caption
                adockpanel.Width = 450
                adockpanel.Visibility = XtraBars.Docking.DockVisibility.AutoHide

                Dim DockImage As Image = CType(e.Link.GetImage().Clone, Image)
                DockImage.RotateFlip(RotateFlipType.Rotate270FlipNone)
                adockpanel.Image = DockImage


                Dim aModule As SecuritySocietyControl = New SecuritySocietyControl("SecuritySociety") With {.Dock = DockStyle.Fill, .PanelName = frmName}
                aModule.KeyFieldName = "SocietyId"
                aModule.ParentFieldName = "ParentSocietyId_FK"
                adockpanel.ControlContainer.Controls.Add(aModule)
                Dim newForm As XtraEditors.XtraForm = New XtraEditors.XtraForm() With {.Name = frmName, .Text = e.Link.Caption, .Icon = ImageExt.ToIcon(e.Link.GetImage(), 16, True), .ShowIcon = True}
                AddHandler newForm.FormClosing, AddressOf MDIForm_Closing
                newForm.MdiParent = Me
            Else
                If DockManager1.Panels(frmName).Visibility = XtraBars.Docking.DockVisibility.Hidden Then
                    DockManager1.Panels(frmName).Visibility = XtraBars.Docking.DockVisibility.AutoHide
                End If
            End If

            Me.Cursor = Cursors.Default
        Else
            If MessageWindow.ShowMessage(DeskTopManager.GetMessage("MES-000001")) = DialogResult.OK Then
                LoadLoginForm()
            End If
        End If
    End Sub

    ''' <summary>
    ''' FRM_????? (GenerateSecurityProfile / Data Subject (Main))
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00061_ItemClick(sender As System.Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles MNU_00061.ItemClick
        Dim dt As DataTable

        If SCIEF.ActiveFramework.CommonExt.Base.AppManager.IsConnected Then
            Me.Cursor = Cursors.WaitCursor
            'second parameter should not be nothing , get the useroption languageID
            dt = SecurityProfiler_PL.GenerateDataSubjectSecurity(Nothing, AppManager.ApplicationOption.LanguageId)
            Me.Cursor = Cursors.Default
        Else
            If MessageWindow.ShowMessage(DeskTopManager.GetMessage("MES-000001")) = DialogResult.OK Then
                LoadLoginForm()
            End If
        End If
    End Sub

    ''' <summary>
    ''' ''' FRM_????? (GenerateSecurityProfile / Subject Filters (Main))
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00062_ItemClick(sender As System.Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles MNU_00062.ItemClick
        Dim dt As DataTable
        If SCIEF.ActiveFramework.CommonExt.Base.AppManager.IsConnected Then
            Me.Cursor = Cursors.WaitCursor
            dt = SecurityProfiler_PL.GenerateDataFieldSecurity(Nothing)
        Else
            If MessageWindow.ShowMessage(DeskTopManager.GetMessage("MES-000001")) = DialogResult.OK Then
                LoadLoginForm()
            End If
        End If
    End Sub

    ''' <summary>
    ''' FRM_???? (GenerateSecurityProfile / User Column)
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00063_ItemClick(sender As System.Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles MNU_00063.ItemClick
        Dim dt As DataTable
        If SCIEF.ActiveFramework.CommonExt.Base.AppManager.IsConnected Then
            Me.Cursor = Cursors.WaitCursor
            dt = SecurityProfiler_PL.GenerateUserColumnSecurity(Nothing, AppManager.ApplicationOption.LanguageId)
            Me.Cursor = Cursors.Default
        Else
            If MessageWindow.ShowMessage(DeskTopManager.GetMessage("MES-000001")) = DialogResult.OK Then
                LoadLoginForm()
            End If
        End If
    End Sub

    ''' <summary>
    ''' FRM_???? (GenerateSecurityProfile / Site Profile)
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00064_ItemClick(sender As System.Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles MNU_00064.ItemClick
        Dim dt As DataTable
        If SCIEF.ActiveFramework.CommonExt.Base.AppManager.IsConnected Then
            Me.Cursor = Cursors.WaitCursor
            dt = SecurityProfiler_PL.GenerateSiteSecurity(Nothing)
            Me.Cursor = Cursors.Default
        Else
            If MessageWindow.ShowMessage(DeskTopManager.GetMessage("MES-000001")) = DialogResult.OK Then
                LoadLoginForm()
            End If
        End If
    End Sub

    ''' <summary>
    ''' FRM_???? (GenerateSecurityProfile / Society Profile)
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00065_ItemClick(sender As System.Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles MNU_00065.ItemClick
        Dim dt As DataTable
        If SCIEF.ActiveFramework.CommonExt.Base.AppManager.IsConnected Then
            Me.Cursor = Cursors.WaitCursor
            dt = SecurityProfiler_PL.GenerateSocietySecurity(Nothing)
            Me.Cursor = Cursors.Default
        Else
            If MessageWindow.ShowMessage(DeskTopManager.GetMessage("MES-000001")) = DialogResult.OK Then
                LoadLoginForm()
            End If
        End If
    End Sub

    ''' <summary>
    ''' FRM_???? (GenerateSecurityProfile / All)
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00066_ItemClick(sender As System.Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles MNU_00066.ItemClick

        If SCIEF.ActiveFramework.CommonExt.Base.AppManager.IsConnected Then
            Me.Cursor = Cursors.WaitCursor
            SystemBoxSDK.PL.MetaSDK.SecurityProfiler_PL.GenerateAllSecurity(AppManager.UserID, AppManager.ApplicationOption.LanguageId)
            SystemBoxSDK.PL.MetaSDK.SecurityProfiler_PL.SaveSecurityProfile(AppManager.UserID)
            Me.Cursor = Cursors.Default
        Else
            If MessageWindow.ShowMessage(DeskTopManager.GetMessage("MES-000001")) = DialogResult.OK Then
                LoadLoginForm()
            End If
        End If
    End Sub

    ''' <summary>
    ''' FRM_00069 (SecurityNavigationMenu)
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00003_FRM_00069(sender As System.Object, e As NavBarLinkEventArgs) Handles MNU_00003.LinkClicked
        aMDIHelper.MNU_FRM_LoadExplorer("FRM_00069", e.Link.Caption, e.Link.GetImage, PLTypeOf.MetaControls_PL, WinCtrlTypeOf.AppComponentExplorer, "AppComponentRoot")
    End Sub

    ''' <summary>
    ''' FRM_00067 (Subject Filters GCCTS)
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00018_LinkClicked(sender As System.Object, e As NavBarLinkEventArgs) Handles MNU_00018.LinkClicked
        Const frmName As String = "SecurityGCCTSList"

        If SCIEF.ActiveFramework.CommonExt.Base.AppManager.IsConnected Then
            Me.Cursor = Cursors.WaitCursor

            If Not FormIsOpen(frmName) Then

                Dim adockpanel As XtraBars.Docking.DockPanel = DockManager1.AddPanel(XtraBars.Docking.DockingStyle.Left)
                adockpanel.FloatVertical = True
                adockpanel.Name = frmName
                adockpanel.Text = e.Link.Caption
                adockpanel.Width = 450
                adockpanel.Visibility = XtraBars.Docking.DockVisibility.AutoHide

                Dim DockImage As Image = CType(e.Link.GetImage().Clone, Image)
                DockImage.RotateFlip(RotateFlipType.Rotate270FlipNone)
                adockpanel.Image = DockImage


                Dim aModule As SecurityListGCCTSControl = New SecurityListGCCTSControl("SecurityGCCTSList") With {.Dock = DockStyle.Fill, .PanelName = frmName}
                aModule.KeyFieldName = "ListID"
                aModule.ParentFieldName = "ParentListID_FK"

                adockpanel.ControlContainer.Controls.Add(aModule)

                Dim newForm As XtraEditors.XtraForm = New XtraEditors.XtraForm() With {.Name = frmName, .Text = e.Link.Caption, .Icon = ImageExt.ToIcon(e.Link.GetImage(), 16, True), .ShowIcon = True}
                AddHandler newForm.FormClosing, AddressOf MDIForm_Closing
                newForm.MdiParent = Me
            Else
                If DockManager1.Panels(frmName).Visibility = XtraBars.Docking.DockVisibility.Hidden Then
                    DockManager1.Panels(frmName).Visibility = XtraBars.Docking.DockVisibility.AutoHide
                End If
            End If
            Me.Cursor = Cursors.Default
        Else
            If MessageWindow.ShowMessage(DeskTopManager.GetMessage("MES-000001")) = DialogResult.OK Then
                LoadLoginForm()
            End If
        End If
    End Sub


    ''' <summary>
    ''' FRM_00068 (SecurityList)
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00005_LinkClicked(sender As System.Object, e As NavBarLinkEventArgs) Handles MNU_00005.LinkClicked
        Const frmName As String = "FRM_00068"
        If SCIEF.ActiveFramework.CommonExt.Base.AppManager.IsConnected Then
            Me.Cursor = Cursors.WaitCursor
            If Not FormIsOpen(frmName) Then
                Dim adockpanel As XtraBars.Docking.DockPanel = DockManager1.AddPanel(XtraBars.Docking.DockingStyle.Left)


                'Dim newForm As XtraEditors.XtraForm = New XtraEditors.XtraForm() With { .Text = "Activity"}
                Dim aModule As New SecurityListControl("SecurityList") With {.Dock = DockStyle.Fill, .PanelName = frmName}
                aModule.KeyFieldName = "Enfant"
                aModule.ParentFieldName = "Parent"

                adockpanel.FloatVertical = True
                adockpanel.Name = frmName
                adockpanel.Text = e.Link.Caption
                adockpanel.Width = 450
                adockpanel.Visibility = XtraBars.Docking.DockVisibility.AutoHide

                Dim DockImage As Image = CType(e.Link.GetImage().Clone, Image)
                DockImage.RotateFlip(RotateFlipType.Rotate270FlipNone)
                adockpanel.Image = DockImage

                '
                adockpanel.ControlContainer.Controls.Add(aModule)
                '
                Dim newForm As XtraEditors.XtraForm = New XtraEditors.XtraForm() With {.Name = frmName, .Text = e.Link.Caption, .Icon = ImageExt.ToIcon(e.Link.GetImage(), 16, True), .ShowIcon = True}
                'InitSpecificationAction(aGridControlexp)
                AddHandler newForm.FormClosing, AddressOf MDIForm_Closing
                newForm.MdiParent = Me
            Else
                If DockManager1.Panels(frmName).Visibility = XtraBars.Docking.DockVisibility.Hidden Then
                    DockManager1.Panels(frmName).Visibility = XtraBars.Docking.DockVisibility.AutoHide
                End If
            End If
            Me.Cursor = Cursors.Default
        Else
            If MessageWindow.ShowMessage(DeskTopManager.GetMessage("MES-000001")) = DialogResult.OK Then
                LoadLoginForm()
            End If
        End If
    End Sub

#End Region

#Region "   Administration  "

    ''' <summary>
    ''' FRM_00066 (DocumentTemplate)
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00045_LinkClicked(ByVal sender As System.Object, ByVal e As NavBarLinkEventArgs) Handles MNU_00045.LinkClicked
        aMDIHelper.MNU_FRM_LoadExplorer("FRM_00066", e.Link.Caption, e.Link.GetImage, PLTypeOf.DocumentTemplate_PL, WinCtrlTypeOf.DocTemplateExplorer, "DocumentTemplateRoot")

    End Sub

    Private Sub MNU_00097_ItemClick(sender As Object, e As XtraBars.ItemClickEventArgs) Handles MNU_00097.ItemClick
        If SCIEF.ActiveFramework.CommonExt.Base.AppManager.IsConnected Then

            Dim sp As SupportForm = New SupportForm()
            sp.ShowDialog()
        Else
            If MessageWindow.ShowMessage(DeskTopManager.GetMessage("MES-000001")) = DialogResult.OK Then
                LoadLoginForm()
            End If
        End If
    End Sub

    ''' <summary>
    ''' FRM_????? (DEV Tool / UpdateSystemRecord)
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks>DEV Tools / Update SystemRecord
    ''' Update all children SystemRecord = True,  who have a parent with a SystemRecord = True </remarks>
    Private Sub MNU_00068_LinkClicked(sender As System.Object, e As DevExpress.XtraNavBar.NavBarLinkEventArgs) Handles MNU_00068.LinkClicked
        If SCIEF.ActiveFramework.CommonExt.Base.AppManager.IsConnected Then
            Dim sqlcmd As System.Data.SqlClient.SqlCommand = Nothing
            Try
                'RUN on SystemBox_Master
                sqlcmd = MetaQuery.GetSPCmdByMetaName("SSPSetSystemRecordParentEnfant")
                sqlcmd.ExecuteNonQuery()
                MessageWindow.ShowMessage("Update SystemRecord in MetaData table Done", MsgBoxStyle.Information)
            Catch sqlex As System.Data.SqlClient.SqlException
                Throw sqlex
            Catch ex As Exception
                Throw ex
            Finally
                If sqlcmd IsNot Nothing Then
                    sqlcmd.Connection.Close()
                    sqlcmd.Dispose()
                End If
            End Try
        Else
            If MessageWindow.ShowMessage(DeskTopManager.GetMessage("MES-000001")) = DialogResult.OK Then
                LoadLoginForm()
            End If
        End If
    End Sub


    ''' <summary>
    ''' FRM_00027_Lists
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00046_FRM_00027_Lists(ByVal sender As System.Object, ByVal e As NavBarLinkEventArgs) Handles MNU_00046.LinkClicked
        aMDIHelper.MNU_FRM_LoadGrid("FRM_00027", e.Link.Caption, e.Link.GetImage(), PLTypeOf.Lists_PL, "Lists", AddressOf aMDIHelper.FRM_00027_Init_GridActionOptionList)
    End Sub

    ''' <summary>
    ''' FRM_00028 (Sequence)
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00044_FRM_00028_LinkClicked(ByVal sender As System.Object, ByVal e As NavBarLinkEventArgs) Handles MNU_00044.LinkClicked
        aMDIHelper.MNU_FRM_LoadGrid("FRM_00028", e.Link.Caption, e.Link.GetImage(), PLTypeOf.Sequence_PL, "Sequence", AddressOf aMDIHelper.FRM00028_Init_GridActionOptionList)

    End Sub

    ''' <summary>
    ''' FRM_00052 (Format)
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks>Application Administration / Format</remarks>
    Private Sub MNU_00079_LinkClicked(sender As System.Object, e As DevExpress.XtraNavBar.NavBarLinkEventArgs) Handles MNU_00079.LinkClicked
        aMDIHelper.MNU_FRM_LoadGrid("FRM_00052", e.Link.Caption, e.Link.GetImage(), PLTypeOf.Format_PL, "Formats", AddressOf aMDIHelper.FRM_00052_Init_GridActionOptionList)
    End Sub


    ''' <summary>
    ''' FRM_????? (Report Builder)
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00048_LinkClicked(sender As System.Object, e As NavBarLinkEventArgs) Handles MNU_00048.LinkClicked
        Const frmName As String = "Report Builder"
        If SCIEF.ActiveFramework.CommonExt.Base.AppManager.IsConnected Then
            Me.Cursor = Cursors.WaitCursor
            If Not FormIsOpen(frmName) Then

                Dim newForm As XtraEditors.XtraForm = New ReportBuilder With {.Name = frmName, .Text = e.Link.Caption, .Icon = ImageExt.ToIcon(e.Link.GetImage(), 16, True), .ShowIcon = True}
                newForm.Show()

            End If

            Me.Cursor = Cursors.Default
        Else
            If MessageWindow.ShowMessage(DeskTopManager.GetMessage("MES-000001")) = DialogResult.OK Then
                LoadLoginForm()
            End If
        End If

    End Sub

    ''' <summary>
    ''' FRM_????? (Document Designer)
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00047_LinkClicked(sender As System.Object, e As NavBarLinkEventArgs) Handles MNU_00047.LinkClicked
        Const frmName As String = "Document Designer"
        If SCIEF.ActiveFramework.CommonExt.Base.AppManager.IsConnected Then
            Me.Cursor = Cursors.WaitCursor
            If Not FormIsOpen(frmName) Then

                Dim newForm As XtraEditors.XtraForm = New DocGen With {.Name = frmName, .Text = e.Link.Caption, .Icon = ImageExt.ToIcon(e.Link.GetImage(), 16, True), .ShowIcon = True}
                newForm.MdiParent = Me
                newForm.Show()

            End If

            Me.Cursor = Cursors.Default
        Else
            If MessageWindow.ShowMessage(DeskTopManager.GetMessage("MES-000001")) = DialogResult.OK Then
                LoadLoginForm()
            End If
        End If
    End Sub

#End Region

#Region " Dev Tool "

    ''' <summary>
    ''' FRM_????? (CodeGeneratorForm)
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00055_LinkClicked(sender As System.Object, e As NavBarLinkEventArgs) Handles MNU_00055.LinkClicked
        If SCIEF.ActiveFramework.CommonExt.Base.AppManager.IsConnected Then
            Me.Cursor = Cursors.WaitCursor
            Dim frm As CodeGeneratorForm = New CodeGeneratorForm() With {.MdiParent = Me, .Text = e.Link.Caption}
            frm.Show()

            Me.Cursor = Cursors.Default
        Else
            If MessageWindow.ShowMessage(DeskTopManager.GetMessage("MES-000001")) = DialogResult.OK Then
                LoadLoginForm()
            End If
        End If
    End Sub

    ''' <summary>
    ''' FRM_????? (DEV Tool / Refresh MetaData)
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks>DEV Tools / Refresh MetaData
    ''' RUN on database who need to be update (you need to have access on the server to SystemBox_Master)</remarks>
    Private Sub MNU_00069_LinkClicked(sender As System.Object, e As DevExpress.XtraNavBar.NavBarLinkEventArgs) Handles MNU_00069.LinkClicked
        If SCIEF.ActiveFramework.CommonExt.Base.AppManager.IsConnected Then
            Dim sqlcmd As System.Data.SqlClient.SqlCommand = Nothing
            Try
                'RUN on database who need to be update (you need to have access on the server to SystemBox_Master)
                sqlcmd = MetaQuery.GetSPCmdByMetaName("SSPMetaDataInsertUpdate")
                sqlcmd.ExecuteNonQuery()
                MessageWindow.ShowMessage("Update of MetaData data (systemrecord only) Done", MsgBoxStyle.Information)
            Catch sqlex As System.Data.SqlClient.SqlException
                Throw sqlex
            Catch ex As Exception
                Throw ex
            Finally
                If sqlcmd IsNot Nothing Then
                    sqlcmd.Connection.Close()
                    sqlcmd.Dispose()
                End If
            End Try
        Else
            If MessageWindow.ShowMessage(DeskTopManager.GetMessage("MES-000001")) = DialogResult.OK Then
                LoadLoginForm()
            End If
        End If
    End Sub

    ''' <summary>
    ''' FRM_????? (DEV Tool / Create Dflt CtrlProps Menu/GrpMenu)
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks>DEV Tools / Create Dflt CtrlProps Menu/GrpMenu
    ''' Create all Default ControlProps for Menu and Group Menu </remarks>
    Private Sub MNU_00070_LinkClicked(sender As System.Object, e As DevExpress.XtraNavBar.NavBarLinkEventArgs) Handles MNU_00070.LinkClicked
        If SCIEF.ActiveFramework.CommonExt.Base.AppManager.IsConnected Then
            Dim sqlcmd As System.Data.SqlClient.SqlCommand = Nothing
            Try
                'RUN on SystemBox_Master
                sqlcmd = MetaQuery.GetSPCmdByMetaName("SSPCreateDfltCtrlPropsMenuGrpMenu")
                sqlcmd.ExecuteNonQuery()
                MessageWindow.ShowMessage("Create default MetaControlProps for Menu and Group Menu Done", MsgBoxStyle.Information)
            Catch sqlex As System.Data.SqlClient.SqlException
                Throw sqlex
            Catch ex As Exception
                Throw ex
            Finally
                If sqlcmd IsNot Nothing Then
                    sqlcmd.Connection.Close()
                    sqlcmd.Dispose()
                End If
            End Try
        Else
            If MessageWindow.ShowMessage(DeskTopManager.GetMessage("MES-000001")) = DialogResult.OK Then
                LoadLoginForm()
            End If
        End If
    End Sub

    ''' <summary>
    ''' FRM_????? (DEV Tool / SQL Diff)
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks>DEV Tools / SQL Diff
    ''' Launch some SQL diff for helping to maintain and generate SQL difference.  Just need to choose witch script you want to use </remarks>
    Private Sub MNU_00071_LinkClicked(sender As System.Object, e As DevExpress.XtraNavBar.NavBarLinkEventArgs) Handles MNU_00071.LinkClicked
        If SCIEF.ActiveFramework.CommonExt.Base.AppManager.IsConnected Then
            Me.Cursor = Cursors.WaitCursor
            Dim frm As SqlDiff = New SqlDiff()
            frm.ShowDialog()
            Me.Cursor = Cursors.Default
        Else
            If MessageWindow.ShowMessage(DeskTopManager.GetMessage("MES-000001")) = DialogResult.OK Then
                LoadLoginForm()
            End If
        End If
    End Sub


#End Region

#Region " Abc "


    ''' <summary>
    ''' GPMN_00024-abC	MNU_00116-abCReport   FRM_00086-abCReportForm
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00116_LinkClicked(sender As Object, e As NavBarLinkEventArgs) Handles MNU_00116.LinkClicked
        Const frmName As String = "FRM_00086"
        Dim adockpanel As XtraBars.Docking.DockPanel
        Dim aModule As ReportExplorer

        If SCIEF.ActiveFramework.CommonExt.Base.AppManager.IsConnected Then
            Me.Cursor = Cursors.WaitCursor

            If Not FormIsOpen(frmName) Then
                adockpanel = DockManager1.AddPanel(XtraBars.Docking.DockingStyle.Left)
                '
                'OUTSTANDINGISSUE: ramener le GroupMenu dans le constructeur au lieu de devoir se souvenir quil faut setter le Group. clieng 2013-04-19.
                aModule = New ReportExplorer("ReportRoot_MNU_00116") With {.Dock = DockStyle.Fill, .PL = Nothing, .PanelName = frmName, .GroupMenuID = IdRepository.GroupMenu.Item("GPMN_00024")}
                '
                adockpanel.FloatVertical = True
                adockpanel.Name = frmName
                adockpanel.Text = e.Link.Caption
                adockpanel.Width = 450
                adockpanel.Visibility = XtraBars.Docking.DockVisibility.Visible
                adockpanel.ControlContainer.Controls.Add(aModule)

                Dim DockImage As Image = CType(e.Link.GetImage().Clone, Image)
                DockImage.RotateFlip(RotateFlipType.Rotate270FlipNone)
                adockpanel.Image = DockImage

            Else
                If DockManager1.Panels(frmName).Visibility = XtraBars.Docking.DockVisibility.Hidden Then
                    DockManager1.Panels(frmName).Visibility = XtraBars.Docking.DockVisibility.AutoHide
                End If
            End If

            Me.Cursor = Cursors.Default
        Else
            '"Please Connect to a Database"
            If MessageWindow.ShowMessage(DeskTopManager.GetMessage("MES-000001")) = DialogResult.OK Then
                LoadLoginForm()
            End If
        End If
    End Sub

    ''' <summary>
    ''' FRM_00075_Account
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00114_FRM_00083_Account(ByVal sender As System.Object, ByVal e As NavBarLinkEventArgs) Handles MNU_00114.LinkClicked

        aMDIHelper.MNU_FRM_LoadExplorer("FRM_00083", e.Link.Caption, e.Link.GetImage, PLTypeOf.Accounts_PL, WinCtrlTypeOf.AccountExplorer, "AccountRoot")
    End Sub

    ''' <summary>
    ''' MNU_00119_FRM_00090_Period
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00119_FRM_00090_Period(sender As Object, e As NavBarLinkEventArgs) Handles MNU_00119.LinkClicked
        aMDIHelper.MNU_FRM_LoadExplorer("FRM_00090", e.Link.Caption, e.Link.GetImage, PLTypeOf.Periods_PL, WinCtrlTypeOf.PeriodExplorer, "PeriodRoot")

    End Sub

#End Region

#Region " ROI "

    ''' <summary>
    ''' GPMN_00010-Return on Information   MNU_00086-ROIReport    FRM_00058-Return on Information Report
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00086_LinkClicked(sender As System.Object, e As DevExpress.XtraNavBar.NavBarLinkEventArgs) Handles MNU_00086.LinkClicked
        Const frmName As String = "FRM_00058"
        Dim adockpanel As XtraBars.Docking.DockPanel
        Dim aModule As ReportExplorer

        If SCIEF.ActiveFramework.CommonExt.Base.AppManager.IsConnected Then
            Me.Cursor = Cursors.WaitCursor

            If Not FormIsOpen(frmName) Then
                adockpanel = DockManager1.AddPanel(XtraBars.Docking.DockingStyle.Left)
                '
                aModule = New ReportExplorer("ReportRoot_MNU_00086") With {.Dock = DockStyle.Fill, .PL = Nothing, .PanelName = frmName, .GroupMenuID = IdRepository.GroupMenu.Item("GPMN_00010")}
                '
                adockpanel.FloatVertical = True
                adockpanel.Name = frmName
                adockpanel.Text = e.Link.Caption
                adockpanel.Width = 450
                adockpanel.Visibility = XtraBars.Docking.DockVisibility.Visible
                adockpanel.ControlContainer.Controls.Add(aModule)

                Dim DockImage As Image = CType(e.Link.GetImage().Clone, Image)
                DockImage.RotateFlip(RotateFlipType.Rotate270FlipNone)
                adockpanel.Image = DockImage

            Else
                If DockManager1.Panels(frmName).Visibility = XtraBars.Docking.DockVisibility.Hidden Then
                    DockManager1.Panels(frmName).Visibility = XtraBars.Docking.DockVisibility.AutoHide
                End If
            End If

            Me.Cursor = Cursors.Default
        Else
            '"Please Connect to a Database"
            If MessageWindow.ShowMessage(DeskTopManager.GetMessage("MES-000001")) = DialogResult.OK Then
                LoadLoginForm()
            End If
        End If
    End Sub

    ''' <summary>
    ''' FRM_00072 (Pivot)
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00008_LinkClicked_FRM_00072_Pivot(ByVal sender As System.Object, ByVal e As NavBarLinkEventArgs) Handles MNU_00008.LinkClicked
        If SCIEF.ActiveFramework.CommonExt.Base.AppManager.IsConnected Then
            Me.Cursor = Cursors.WaitCursor
            Dim newForm As XtraEditors.XtraForm = New XtraEditors.XtraForm() With {.Text = e.Link.Caption, .Icon = ImageExt.ToIcon(e.Link.GetImage(), 16, True), .ShowIcon = True}
            Dim aModule As New PivotExt("PIVOTSOURCE") With {.Dock = DockStyle.Fill}
            newForm.Controls.Add(aModule)
            AddHandler newForm.FormClosing, AddressOf HidingFieldsList
            aModule.PivotGridControl1.OptionsCustomization.CustomizationFormStyle = DevExpress.XtraPivotGrid.Customization.CustomizationFormStyle.Excel2007

            newForm.MdiParent = Me
            newForm.Show()
            FieldDockPanel.Width = 500

            Dim DockImage As Image = CType(e.Link.GetImage().Clone, Image)
            DockImage.RotateFlip(RotateFlipType.Rotate270FlipNone)
            FieldDockPanel.Image = DockImage


            FieldDockPanel.Visibility = XtraBars.Docking.DockVisibility.AutoHide
            aModule.PivotGridControl1.FieldsCustomization(FieldDockPanel)
            Me.Cursor = Cursors.Default
        Else
            If MessageWindow.ShowMessage(DeskTopManager.GetMessage("MES-000001")) = DialogResult.OK Then
                LoadLoginForm()
            End If
        End If
    End Sub


    Private Sub HidingFieldsList(ByVal sender As Object, ByVal e As FormClosingEventArgs)
        FieldDockPanel.Visibility = XtraBars.Docking.DockVisibility.Hidden
    End Sub




    ''' <summary>
    ''' FRM_00055 (Audit)
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00080_LinkClicked(sender As System.Object, e As DevExpress.XtraNavBar.NavBarLinkEventArgs) Handles MNU_00080.LinkClicked

        Const frmName As String = "FRM_00055"
        Dim adockpanel As XtraBars.Docking.DockPanel
        Dim aModule As ViewExplorer

        If SCIEF.ActiveFramework.CommonExt.Base.AppManager.IsConnected Then
            Me.Cursor = Cursors.WaitCursor
            If Not FormIsOpen(frmName) Then
                adockpanel = DockManager1.AddPanel(XtraBars.Docking.DockingStyle.Left)
                '
                aModule = New ViewExplorer("ViewExplorer", "CommandCategoryID_FK = '1d308b36-fb54-44d4-af61-fa46bb31f8b6'") With {.Dock = DockStyle.Fill, .PL = Nothing, .PanelName = frmName}
                'aModule.Hierarchie = False
                '
                adockpanel.FloatVertical = True
                adockpanel.Name = frmName
                adockpanel.Text = e.Link.Caption
                adockpanel.Width = 450
                adockpanel.Visibility = XtraBars.Docking.DockVisibility.AutoHide
                adockpanel.ControlContainer.Controls.Add(aModule)


                Dim DockImage As Image = CType(e.Link.GetImage().Clone, Image)
                DockImage.RotateFlip(RotateFlipType.Rotate270FlipNone)
                adockpanel.Image = DockImage



                '
                Dim newForm As XtraEditors.XtraForm = New XtraEditors.XtraForm() With {.Name = frmName, .Text = e.Link.Caption, .Icon = ImageExt.ToIcon(e.Link.GetImage(), 16, True), .ShowIcon = True}
                AddHandler newForm.FormClosing, AddressOf MDIForm_Closing
                newForm.MdiParent = Me
            Else
                If DockManager1.Panels(frmName).Visibility = XtraBars.Docking.DockVisibility.Hidden Then
                    DockManager1.Panels(frmName).Visibility = XtraBars.Docking.DockVisibility.AutoHide
                End If
            End If
            Me.Cursor = Cursors.Default
        Else
            If MessageWindow.ShowMessage(DeskTopManager.GetMessage("MES-000001")) = DialogResult.OK Then
                LoadLoginForm()
            End If
        End If
    End Sub


    ''' <summary>
    '''FRM_00060 / View
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00089_LinkClicked(sender As System.Object, e As DevExpress.XtraNavBar.NavBarLinkEventArgs) Handles MNU_00089.LinkClicked
        Const frmName As String = "FRM_00060"
        Dim adockpanel As XtraBars.Docking.DockPanel
        Dim aModule As ViewExplorer

        If SCIEF.ActiveFramework.CommonExt.Base.AppManager.IsConnected Then
            Me.Cursor = Cursors.WaitCursor
            If Not FormIsOpen(frmName) Then
                adockpanel = DockManager1.AddPanel(XtraBars.Docking.DockingStyle.Left)
                '
                aModule = New ViewExplorer("ViewExplorer", "CommandCategoryID_FK = '3062AAF4-F21F-4123-99BE-C43B5F0AC25A'") With {.Dock = DockStyle.Fill, .PL = Nothing, .PanelName = frmName}
                ' aModule.Hierarchie = False
                '
                adockpanel.FloatVertical = True
                adockpanel.Name = frmName
                adockpanel.Text = e.Link.Caption
                adockpanel.Width = 450
                adockpanel.Visibility = XtraBars.Docking.DockVisibility.AutoHide
                adockpanel.ControlContainer.Controls.Add(aModule)

                If Not e.Link.GetImage() Is Nothing Then
                    Dim DockImage As Image = CType(e.Link.GetImage().Clone, Image)
                    DockImage.RotateFlip(RotateFlipType.Rotate270FlipNone)
                    adockpanel.Image = DockImage

                End If


                '
                Dim newForm As XtraEditors.XtraForm = New XtraEditors.XtraForm() With {.Name = frmName, .Text = e.Link.Caption, .Icon = ImageExt.ToIcon(e.Link.GetImage(), 16, True), .ShowIcon = True}
                AddHandler newForm.FormClosing, AddressOf MDIForm_Closing
                newForm.MdiParent = Me
            Else
                If DockManager1.Panels(frmName).Visibility = XtraBars.Docking.DockVisibility.Hidden Then
                    DockManager1.Panels(frmName).Visibility = XtraBars.Docking.DockVisibility.AutoHide
                End If
            End If
            Me.Cursor = Cursors.Default
        Else
            If MessageWindow.ShowMessage(DeskTopManager.GetMessage("MES-000001")) = DialogResult.OK Then
                LoadLoginForm()
            End If
        End If
    End Sub



#End Region

#Region " Service "
    Private Sub InitTimeSheetGridPL(ByVal grid As GridExtPL, ByVal withChild As Boolean)
        Dim plTmehrs As SystemBoxSDK.PL.TSMSDK.TimeSheet_PL = Nothing
        Try
            plTmehrs = New SystemBoxSDK.PL.TSMSDK.TimeSheet_PL("TimeSheet")
            plTmehrs.InitData()
            grid.Dataset = plTmehrs.Dataset
            grid.MetaDataTable = plTmehrs.MetaDataTable
        Catch ex As Exception
            MessageWindow.ShowMessage(ex, MsgBoxStyle.Information)
        End Try
    End Sub

    ''' <summary>
    ''' FRM_00054_Activity
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00001_FRM_00054_Activity(ByVal sender As System.Object, ByVal e As NavBarLinkEventArgs) Handles MNU_00001.LinkClicked

        Const frmName As String = "FRM_00054"

        If SCIEF.ActiveFramework.CommonExt.Base.AppManager.IsConnected Then
            Me.Cursor = Cursors.WaitCursor

            'J'ai tu le droit a cette fonction/Form

            If Not FormIsOpen(frmName) Then

                Dim adockpanel As XtraBars.Docking.DockPanel = DockManager1.AddPanel(XtraBars.Docking.DockingStyle.Left)
                adockpanel.FloatVertical = True
                adockpanel.Name = frmName
                adockpanel.Text = e.Link.Caption
                adockpanel.Width = 500

                Dim DockImage As Image = CType(e.Link.GetImage().Clone, Image)
                DockImage.RotateFlip(RotateFlipType.Rotate270FlipNone)
                adockpanel.Image = DockImage
                adockpanel.Visibility = XtraBars.Docking.DockVisibility.AutoHide

                Dim aGridControlexp As ActivityExplorer
                aGridControlexp = TryCast(WinCtrlBase.CreateInstanceOf(WinCtrlTypeOf.ActivityExplorer), ActivityExplorer)
                aGridControlexp.QueryName = "ProjectRoot"
                aGridControlexp.Dock = DockStyle.Fill
                aGridControlexp.PanelName = frmName
                aGridControlexp.PL = PLBase.CreateInstanceOf(PLTypeOf.Project_PL, "Activity")
                aGridControlexp.KeyFieldName = "KeyID"
                aGridControlexp.ParentFieldName = "ParentID"

                adockpanel.ControlContainer.Controls.Add(aGridControlexp)

                Dim newForm As XtraEditors.XtraForm = New XtraEditors.XtraForm() With {.Name = frmName, .Text = e.Link.Caption, .Icon = ImageExt.ToIcon(e.Link.GetImage(), 16, True), .ShowIcon = True}
                AddHandler newForm.FormClosing, AddressOf MDIForm_Closing
                newForm.MdiParent = Me
            Else
                If DockManager1.Panels(frmName).Visibility = XtraBars.Docking.DockVisibility.Hidden Then
                    DockManager1.Panels(frmName).Visibility = XtraBars.Docking.DockVisibility.AutoHide
                End If
            End If

            Me.Cursor = Cursors.Default
        Else
            If MessageWindow.ShowMessage(DeskTopManager.GetMessage("MES-000001")) = DialogResult.OK Then
                LoadLoginForm()
            End If
        End If


    End Sub


    ''' <summary>
    ''' MNU_00115_FRM_00085_Myshedule
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00115_FRM_00085_Myshedule(sender As Object, e As NavBarLinkEventArgs) Handles MNU_00115.LinkClicked
        Const frmName As String = "FRM_00085"

        If SCIEF.ActiveFramework.CommonExt.Base.AppManager.IsConnected Then

            'If Not FormIsOpen(frmName) Then
            Me.Cursor = Cursors.WaitCursor
            'Howto: la propriété .FormCtrlCD  est l'interface avec lequel le GridExtPl obtient le CRUD security si le frmName est égal à un Metacontrol Name de Forme
            Dim pl As SystemBoxSDK.PL.Void_PL = New SystemBoxSDK.PL.Void_PL("MyScheduleBy")
            Dim newForm As MySchedulerControl = New MySchedulerControl With {.Pl = pl, .FormName = frmName, .Name = frmName, .Text = e.Link.Caption, .Icon = ImageExt.ToIcon(e.Link.GetImage(), 16, True), .ShowIcon = True}
            AddHandler newForm.FormClosing, AddressOf MDIForm_Closing
            Me.Cursor = Cursors.Default
            newForm.Show()
            newForm.MdiParent = Me
            'End If

        Else
            '"Please Connect to a Database"
            If MessageWindow.ShowMessage(DeskTopManager.GetMessage("MES-000001")) = DialogResult.OK Then
                LoadLoginForm()
            End If
        End If
    End Sub

    ''' <summary>
    ''' MyTimeSheet
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00101_FRM_00073(sender As Object, e As NavBarLinkEventArgs) Handles MNU_00101.LinkClicked
        '*****************************************
        Const frmName As String = "FRM_00073"
        Dim aModule As SystemBoxWinSDK.TimeSheetExplorer

        ' the explorer is instanciated just to have access to the partial class.
        aModule = New SystemBoxWinSDK.TimeSheetExplorer("TimeSheetExplorer")
        aModule.EmplID = Employee_PL.GetEmployeeIdByUserName(AppManager.UserName)
        '

        If SCIEF.ActiveFramework.CommonExt.Base.AppManager.IsConnected Then
            Me.Cursor = Cursors.WaitCursor
            Dim plTmSht As TimeSheet_PL = New SystemBoxSDK.PL.TSMSDK.TimeSheet_PL("TimeSheetClient")
            Dim newForm As XtraEditors.XtraForm = New XtraEditors.XtraForm() With {.Text = e.Link.Caption, .Icon = ImageExt.ToIcon(e.Link.GetImage(), 16, True), .ShowIcon = True}
            Dim aTimeSheetGridExpl As GridExtPL = New GridExtPL() With {.Dock = DockStyle.Fill, .FormCtrlCD = frmName}

            aTimeSheetGridExpl.Pl = plTmSht
            aTimeSheetGridExpl.SecureGrid = True
            aModule.aGridControl = aTimeSheetGridExpl



            plTmSht.SQLWhere = String.Format("MU.UserName = '{0}' AND Approved = 0", AppManager.UserName)

            '-------- Colle PL-----------------'
            AddHandler aTimeSheetGridExpl.ValidateMasterRow, AddressOf aModule.ValidateMasterRow
            AddHandler aTimeSheetGridExpl.ValidateDetailRow, AddressOf aModule.ValidateDetailRow
            AddHandler aTimeSheetGridExpl.InitNewMasterRow, AddressOf aModule.InitNewMasterRow
            AddHandler aTimeSheetGridExpl.InitNewDetailRow, AddressOf aModule.InitNewDetailRow
            AddHandler aTimeSheetGridExpl.DeleteRow, AddressOf aModule.DeleteRow

            AddHandler aTimeSheetGridExpl.ProcessCurrentMasterRecord, AddressOf aModule.ProcessCurrentMasterRecord
            AddHandler aTimeSheetGridExpl.ProcessCurrentDetailRecord, AddressOf aModule.ProcessCurrentDetailRecord
            AddHandler aTimeSheetGridExpl.ShownMasterEditor, AddressOf aModule.ShownMasterEditor

            AddHandler aTimeSheetGridExpl.ShownDetailEditor, AddressOf aModule.ShownDetailEditor
            AddHandler aTimeSheetGridExpl.HiddenDetailEditor, AddressOf aModule.HiddenDetailEditor

            Dim action As ActionOption
            'submit
            action = New ActionOption("Timesheet", "Submit", "Submit", AddressOf aModule.MenuSubmit, True, True)
            aTimeSheetGridExpl.GridActionOptionList.Add(action)
            action = New ActionOption("Timesheet", "UnSubmit", "UnSubmit", AddressOf aModule.MenuUnSubmit, True, True)
            aTimeSheetGridExpl.GridActionOptionList.Add(action)
            action = New ActionOption("Timesheet", "New", "New Time Sheet", AddressOf aModule.MenuNew, True, True)
            aTimeSheetGridExpl.GridActionOptionList.Add(action)
            action = New ActionOption("TimesheetDetail", "Copy", "Copy entry", AddressOf aModule.CopyTimesheetEntry, True, True, "TimeSheetHourClient")
            aTimeSheetGridExpl.GridActionOptionList.Add(action)



            newForm.Controls.Add(aTimeSheetGridExpl)
            newForm.MdiParent = Me
            newForm.Show()
            Me.Cursor = Cursors.Default
        Else
            If MessageWindow.ShowMessage(DeskTopManager.GetMessage("MES-000001")) = DialogResult.OK Then
                LoadLoginForm()
            End If
        End If


    End Sub


    ''' <summary>
    ''' GPMN_00013-Service 	MNU_00104-ServiceReport  FRM_00076-ServiceReportForm
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00104_LinkPressed(sender As Object, e As NavBarLinkEventArgs) Handles MNU_00104.LinkPressed
        Const frmName As String = "FRM_00076"
        Dim adockpanel As XtraBars.Docking.DockPanel
        Dim aModule As ReportExplorer

        If SCIEF.ActiveFramework.CommonExt.Base.AppManager.IsConnected Then
            Me.Cursor = Cursors.WaitCursor

            If Not FormIsOpen(frmName) Then
                adockpanel = DockManager1.AddPanel(XtraBars.Docking.DockingStyle.Left)
                '
                'OUTSTANDINGISSUE: ramener le GroupMenu dans le constructeur au lieu de devoir se souvenir quil faut setter le Group. clieng 2013-04-19.
                aModule = New ReportExplorer("ReportRoot_MNU_00104") With {.Dock = DockStyle.Fill, .PL = Nothing, .PanelName = frmName, .GroupMenuID = IdRepository.GroupMenu.Item("GPMN_00013")}
                '
                adockpanel.FloatVertical = True
                adockpanel.Name = frmName
                adockpanel.Text = e.Link.Caption
                adockpanel.Width = 450
                adockpanel.Visibility = XtraBars.Docking.DockVisibility.Visible
                adockpanel.ControlContainer.Controls.Add(aModule)

                Dim DockImage As Image = CType(e.Link.GetImage().Clone, Image)
                DockImage.RotateFlip(RotateFlipType.Rotate270FlipNone)
                adockpanel.Image = DockImage

            Else
                If DockManager1.Panels(frmName).Visibility = XtraBars.Docking.DockVisibility.Hidden Then
                    DockManager1.Panels(frmName).Visibility = XtraBars.Docking.DockVisibility.AutoHide
                End If
            End If

            Me.Cursor = Cursors.Default
        Else
            '"Please Connect to a Database"
            If MessageWindow.ShowMessage(DeskTopManager.GetMessage("MES-000001")) = DialogResult.OK Then
                LoadLoginForm()
            End If
        End If
    End Sub

    ''' <summary>
    ''' FRM_00057  (Scheduler)
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00084_LinkClicked(sender As System.Object, e As DevExpress.XtraNavBar.NavBarLinkEventArgs) Handles MNU_00084.LinkClicked
        Const frmName As String = "FRM_00057"

        If SCIEF.ActiveFramework.CommonExt.Base.AppManager.IsConnected Then

            'If Not FormIsOpen(frmName) Then
            Me.Cursor = Cursors.WaitCursor
            'Howto: la propriété .FormCtrlCD  est l'interface avec lequel le GridExtPl obtient le CRUD security si le frmName est égal à un Metacontrol Name de Forme
            Dim pl As SystemBoxSDK.PL.MESSDK.Appointment_PL = New SystemBoxSDK.PL.MESSDK.Appointment_PL("AppointmentBy")
            Dim newForm As ApptSchedulerControl = New ApptSchedulerControl With {.Pl = pl, .FormName = frmName, .Name = frmName, .Text = e.Link.Caption, .Icon = ImageExt.ToIcon(e.Link.GetImage(), 16, True), .ShowIcon = True}
            AddHandler newForm.FormClosing, AddressOf MDIForm_Closing
            Me.Cursor = Cursors.Default
            newForm.MdiParent = Me
            'End If

        Else
            '"Please Connect to a Database"
            If MessageWindow.ShowMessage(DeskTopManager.GetMessage("MES-000001")) = DialogResult.OK Then
                LoadLoginForm()
            End If
        End If

    End Sub



    ''' <summary>
    ''' FRM_00014 (Timesheet)
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00019_FRM_00014_Timesheet(ByVal sender As System.Object, ByVal e As NavBarLinkEventArgs) Handles MNU_00019.LinkClicked

        '*****************************************
        Const frmName As String = "FRM_00014"
        Dim adockpanel As XtraBars.Docking.DockPanel
        Dim aModule As SystemBoxWinSDK.TimeSheetExplorer

        If SCIEF.ActiveFramework.CommonExt.Base.AppManager.IsConnected Then
            Me.Cursor = Cursors.WaitCursor
            If Not FormIsOpen(frmName) Then
                adockpanel = DockManager1.AddPanel(XtraBars.Docking.DockingStyle.Left)
                '
                aModule = New SystemBoxWinSDK.TimeSheetExplorer("TimeSheetTreeRoot") With {.Dock = DockStyle.Fill, .PL = New PL.TSMSDK.TimeSheet_PL("TimeSheet"), .PanelName = frmName}
                aModule.KeyFieldName = "KeyID"
                aModule.ParentFieldName = "ParentID"
                '
                adockpanel.FloatVertical = True
                adockpanel.Name = frmName
                adockpanel.Text = e.Link.Caption
                adockpanel.Width = 450
                adockpanel.Visibility = XtraBars.Docking.DockVisibility.AutoHide
                adockpanel.ControlContainer.Controls.Add(aModule)

                Dim DockImage As Image = CType(e.Link.GetImage().Clone, Image)
                DockImage.RotateFlip(RotateFlipType.Rotate270FlipNone)
                adockpanel.Image = DockImage

                '
                Dim newForm As XtraEditors.XtraForm = New XtraEditors.XtraForm() With {.Name = frmName, .Text = e.Link.Caption, .Icon = ImageExt.ToIcon(e.Link.GetImage(), 16, True), .ShowIcon = True}
                AddHandler newForm.FormClosing, AddressOf MDIForm_Closing
                newForm.MdiParent = Me
            Else
                If DockManager1.Panels(frmName).Visibility = XtraBars.Docking.DockVisibility.Hidden Then
                    DockManager1.Panels(frmName).Visibility = XtraBars.Docking.DockVisibility.AutoHide
                End If
            End If
            Me.Cursor = Cursors.Default
        Else
            If MessageWindow.ShowMessage(DeskTopManager.GetMessage("MES-000001")) = DialogResult.OK Then
                LoadLoginForm()
            End If
        End If
    End Sub


    Private Sub PrintTimeDetail(ByVal sender As System.Object, ByVal e As EventArgs)
        If SCIEF.ActiveFramework.CommonExt.Base.AppManager.IsConnected Then
            Me.Cursor = Cursors.WaitCursor

            Dim aDataRow As DataRow = CType(CType(sender, DXMenuItem).Tag, DataRow)

            Dim Report As TimeSheetHoursReport = New TimeSheetHoursReport() With {.ParamOrderNo = aDataRow("OrderNo").ToString}
            Report.CreateDocument()
            Dim aFrm As Form = New ReportPrintForm() With {.MdiParent = Me, .Text = "Print Time Details", .Report = Report}
            aFrm.Show()
            Me.Cursor = Cursors.Default

        Else
            If MessageWindow.ShowMessage(DeskTopManager.GetMessage("MES-000001")) = DialogResult.OK Then
                LoadLoginForm()
            End If
        End If
    End Sub

    Private Sub LinkTimesheet(ByVal sender As System.Object, ByVal e As EventArgs)
        If SCIEF.ActiveFramework.CommonExt.Base.AppManager.IsConnected Then
            Me.Cursor = Cursors.WaitCursor

            Dim aDataRow As DataRow = CType(CType(sender, DXMenuItem).Tag, DataRow)

            Try
                ' Need to review Logic : B.Desjardins
                'If Not String.IsNullOrEmpty(aDataRow("InvoiceNo").ToString) Then

                Dim frm As SetInvoicedTimecardForm = New SetInvoicedTimecardForm() With {.ParamOrderNo = CType(aDataRow("SalesOrderId"), Guid), .ParamCustID = CType(aDataRow("CustomerId_FK"), Guid)}

                Dim result As DialogResult = frm.ShowDialog()

                If result = DialogResult.OK Then
                    MessageWindow.ShowMessage("Timesheet invoiced")
                Else
                    'error occured
                End If

                'Else
                '    MessageWindow.ShowMessage("You must first Generate Invoice No", MsgBoxStyle.Information)
                'End If

            Catch ex As Exception
                MessageWindow.ShowMessage(ex, MsgBoxStyle.Information)
            End Try

            Me.Cursor = Cursors.Default
        Else
            If MessageWindow.ShowMessage(DeskTopManager.GetMessage("MES-000001")) = DialogResult.OK Then
                LoadLoginForm()
            End If
        End If
    End Sub

#End Region ' " Service "

#Region " Orders "

    ''' <summary>
    '''GPMN_00001-Order Mangement	MNU_00105-OrderManagementReport  FRM_00077-OrderManagementReportForm
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00105_LinkPressed(sender As Object, e As NavBarLinkEventArgs) Handles MNU_00105.LinkPressed
        Const frmName As String = "FRM_00077"

        Dim adockpanel As XtraBars.Docking.DockPanel
        Dim aModule As ReportExplorer

        If Not FormIsOpen(frmName) Then
            adockpanel = DockManager1.AddPanel(XtraBars.Docking.DockingStyle.Left)
            '
            'OUTSTANDINGISSUE: ramener le GroupMenu dans le constructeur au lieu de devoir se souvenir quil faut setter le Group. clieng 2013-04-19.
            aModule = New ReportExplorer("ReportRoot_MNU_00105") With {.Dock = DockStyle.Fill, .PL = Nothing, .PanelName = frmName, .GroupMenuID = IdRepository.GroupMenu.Item("GPMN_00001")}
            '
            adockpanel.FloatVertical = True
            adockpanel.Name = frmName
            adockpanel.Text = e.Link.Caption
            adockpanel.Width = 450
            adockpanel.Visibility = XtraBars.Docking.DockVisibility.Visible
            adockpanel.ControlContainer.Controls.Add(aModule)
        Else
            If DockManager1.Panels(frmName).Visibility = XtraBars.Docking.DockVisibility.Hidden Then
                DockManager1.Panels(frmName).Visibility = XtraBars.Docking.DockVisibility.AutoHide
            End If
        End If

        Me.Cursor = Cursors.Default
    End Sub



    ''' <summary>
    ''' FRM_00053 (Society)
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00015_LinkClicked_FRM_00053_Society(ByVal sender As System.Object, ByVal e As NavBarLinkEventArgs) Handles MNU_00015.LinkClicked

        aMDIHelper.MNU_FRM_LoadExplorer("FRM_00053", e.Link.Caption, e.Link.GetImage, PLTypeOf.Society_PL, WinCtrlTypeOf.SocietyExplorer, "SocietyRoot")

    End Sub

    ''' <summary>
    ''' FRM_00035 (Purchase Orders)
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00023_LinkClicked_FRM_00035_Purchase_Orders(ByVal sender As System.Object, ByVal e As NavBarLinkEventArgs) Handles MNU_00023.LinkClicked
        aMDIHelper.MNU_FRM_LoadExplorer("FRM_00035", e.Link.Caption, e.Link.GetImage, PLTypeOf.PurchaseOrder_PL, WinCtrlTypeOf.PurchaseOrderExplorer, "PurchaseOrderRoot")

    End Sub

    ''' <summary>
    ''' FRM_00034 (OrderHeader)
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00021_LinkClicked_FRM_00034_OrderHeader(sender As System.Object, e As NavBarLinkEventArgs) Handles MNU_00021.LinkClicked


    End Sub

    ''' <summary>
    ''' FRM_00036 (Sales Orders)
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00022_LinkClicked_FRM_00036_Sales_Orders(ByVal sender As System.Object, ByVal e As NavBarLinkEventArgs) Handles MNU_00022.LinkClicked
        aMDIHelper.MNU_FRM_LoadExplorer("FRM_00036", e.Link.Caption, e.Link.GetImage, PLTypeOf.SalesOrder_PL, WinCtrlTypeOf.SalesOrderExplorer, "SalesOrderRoot")

    End Sub

#End Region ' " Orders "

#Region " Inventory "

    ''' <summary>
    ''' GPMN_00006-Inventory   MNU_00093-InventoryReport   FRM_00063-InventoryReportForm
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00093_LinkClicked(sender As Object, e As NavBarLinkEventArgs) Handles MNU_00093.LinkClicked
        Const frmName As String = "FRM_00063"
        Dim adockpanel As XtraBars.Docking.DockPanel
        Dim aModule As ReportExplorer

        If SCIEF.ActiveFramework.CommonExt.Base.AppManager.IsConnected Then
            Me.Cursor = Cursors.WaitCursor

            If Not FormIsOpen(frmName) Then
                adockpanel = DockManager1.AddPanel(XtraBars.Docking.DockingStyle.Left)
                '
                aModule = New ReportExplorer("ReportRoot_MNU_00093") With {.Dock = DockStyle.Fill, .PL = Nothing, .PanelName = frmName, .GroupMenuID = IdRepository.GroupMenu.Item("GPMN_00006")}
                '
                adockpanel.FloatVertical = True
                adockpanel.Name = frmName
                adockpanel.Text = e.Link.Caption
                adockpanel.Width = 450
                adockpanel.Visibility = XtraBars.Docking.DockVisibility.Visible
                adockpanel.ControlContainer.Controls.Add(aModule)

                Dim DockImage As Image = CType(e.Link.GetImage().Clone, Image)
                DockImage.RotateFlip(RotateFlipType.Rotate270FlipNone)
                adockpanel.Image = DockImage

            Else
                If DockManager1.Panels(frmName).Visibility = XtraBars.Docking.DockVisibility.Hidden Then
                    DockManager1.Panels(frmName).Visibility = XtraBars.Docking.DockVisibility.AutoHide
                End If
            End If

            Me.Cursor = Cursors.Default
        Else
            '"Please Connect to a Database"
            If MessageWindow.ShowMessage(DeskTopManager.GetMessage("MES-000001")) = DialogResult.OK Then
                LoadLoginForm()
            End If
        End If
    End Sub


    ''' <summary>
    ''' FRM_00004_InventoryBatchsExplorer
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00004_FRM_00004_InventoryBatchsExplorer(ByVal sender As System.Object, ByVal e As NavBarLinkEventArgs) Handles MNU_00004.LinkClicked

        aMDIHelper.MNU_FRM_LoadExplorer("FRM_00004", e.Link.Caption, e.Link.GetImage, PLTypeOf.InventoryBatchs_PL, WinCtrlTypeOf.InventoryBatchExplorer, "InvBatchsRoot")

    End Sub


    ''' <summary>
    ''' FRM_00031_InventoryCountSheet
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00034_FRM_00031_InventoryCountSheet(ByVal sender As System.Object, ByVal e As NavBarLinkEventArgs) Handles MNU_00034.LinkClicked

        aMDIHelper.MNU_FRM_LoadExplorer("FRM_00031", e.Link.Caption, e.Link.GetImage, PLTypeOf.InvCountHeader_PL, WinCtrlTypeOf.InvCountExplorer, "InvCountRoot")

    End Sub

    ''' <summary>
    ''' MNU_00013_FRM_00045_Site
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00013_FRM_00045_Site(sender As System.Object, e As NavBarLinkEventArgs) Handles MNU_00013.LinkClicked

        aMDIHelper.MNU_FRM_LoadExplorer("FRM_00045", e.Link.Caption, e.Link.GetImage, PLTypeOf.Site_PL, WinCtrlTypeOf.SiteExplorer, "SiteRoot")

    End Sub

#End Region ' " Inventory "

#Region " Production "


    ''' <summary>
    ''' GPMN_00008-Production   MNU_00092-ProductionReport   FRM_00062-ProductionReportForm
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00092_LinkClicked(sender As Object, e As NavBarLinkEventArgs) Handles MNU_00092.LinkClicked
        Const frmName As String = "FRM_00062"
        Dim adockpanel As XtraBars.Docking.DockPanel
        Dim aModule As ReportExplorer

        If SCIEF.ActiveFramework.CommonExt.Base.AppManager.IsConnected Then
            Me.Cursor = Cursors.WaitCursor

            If Not FormIsOpen(frmName) Then
                adockpanel = DockManager1.AddPanel(XtraBars.Docking.DockingStyle.Left)
                '
                aModule = New ReportExplorer("ReportRoot_MNU_00092") With {.Dock = DockStyle.Fill, .PL = Nothing, .PanelName = frmName, .GroupMenuID = IdRepository.GroupMenu.Item("GPMN_00008")}
                '
                adockpanel.FloatVertical = True
                adockpanel.Name = frmName
                adockpanel.Text = e.Link.Caption
                adockpanel.Width = 450
                adockpanel.Visibility = XtraBars.Docking.DockVisibility.Visible
                adockpanel.ControlContainer.Controls.Add(aModule)

                Dim DockImage As Image = CType(e.Link.GetImage().Clone, Image)
                DockImage.RotateFlip(RotateFlipType.Rotate270FlipNone)
                adockpanel.Image = DockImage

            Else
                If DockManager1.Panels(frmName).Visibility = XtraBars.Docking.DockVisibility.Hidden Then
                    DockManager1.Panels(frmName).Visibility = XtraBars.Docking.DockVisibility.AutoHide
                End If
            End If

            Me.Cursor = Cursors.Default
        Else
            '"Please Connect to a Database"
            If MessageWindow.ShowMessage(DeskTopManager.GetMessage("MES-000001")) = DialogResult.OK Then
                LoadLoginForm()
            End If
        End If
    End Sub



    ''' <summary>
    ''' FRM_00037_ProductionOrder
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00006_FRM_00037_ProductionOrder(ByVal sender As System.Object, ByVal e As NavBarLinkEventArgs) Handles MNU_00006.LinkClicked
        aMDIHelper.MNU_FRM_LoadExplorer("FRM_00037", e.Link.Caption, e.Link.GetImage, PLTypeOf.Lot_PL, WinCtrlTypeOf.ProductionOrderExplorer, "ProdOrderRoot")

    End Sub

    Private Sub MNU_00111_LinkClicked(sender As Object, e As NavBarLinkEventArgs) Handles MNU_00111.LinkClicked
        If SCIEF.ActiveFramework.CommonExt.Base.AppManager.IsConnected Then
            Me.Cursor = Cursors.WaitCursor
            Dim aModule As DevExpress.XtraEditors.XtraUserControl
            Dim chgsts As SystemBoxWinSDK.ChangeStatusControl
            aModule = SystemBoxWinSDK.Win.WinCtrlBase.CreateInstanceOf(WinCtrlTypeOf.ChangeStatusControl)
            chgsts = CType(aModule, ChangeStatusControl)
            chgsts.QueryName = "ChangeLotStatusStock"
            chgsts.Dock = DockStyle.Fill
            Dim newForm As XtraEditors.XtraForm = New XtraEditors.XtraForm() With {.Text = e.Link.Caption, .Icon = ImageExt.ToIcon(e.Link.GetImage(), 16, True), .ShowIcon = True}
            newForm.Controls.Add(chgsts)
            newForm.MdiParent = Me
            Me.Cursor = Cursors.Default
        Else
            If MessageWindow.ShowMessage(DeskTopManager.GetMessage("MES-000001")) = DialogResult.OK Then
                LoadLoginForm()
            End If
        End If
    End Sub


    ''' <summary>
    ''' FRM_00056 (Work Order)
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00081_LinkClicked(sender As System.Object, e As DevExpress.XtraNavBar.NavBarLinkEventArgs) Handles MNU_00081.LinkClicked
        aMDIHelper.MNU_FRM_LoadExplorer("FRM_00056", e.Link.Caption, e.Link.GetImage, PLTypeOf.MRPHeader_PL, WinCtrlTypeOf.WorkOrderExplorer, "WorkOrderRoot")

    End Sub



    ''' <summary>
    ''' FRM_????? (LotTransaction)
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00035_LinkClicked(ByVal sender As System.Object, ByVal e As NavBarLinkEventArgs) Handles MNU_00035.LinkClicked

        'OUTSTANDING ISSUE: Tres long a loader car il y 2 LOV sur la table Lot
        If SCIEF.ActiveFramework.CommonExt.Base.AppManager.IsConnected Then
            Me.Cursor = Cursors.WaitCursor
            'Dim plLt As PL.MESSDK.LotTransaction_PL = New PL.MESSDK.LotTransaction_PL("LotTransactionPL")
            Dim newForm As XtraEditors.XtraForm = New XtraEditors.XtraForm() With {.Text = e.Link.Caption, .Icon = ImageExt.ToIcon(e.Link.GetImage(), 16, True), .ShowIcon = True}
            AddHandler newForm.FormClosing, AddressOf MDIForm_Closing
            'Dim x As GridExtPL = New GridExtPL() With {.Dock = DockStyle.Fill}
            'x.Pl = plLt
            Dim aGridControlexp As New ExplorerTreeList("ProjectRoot") With {.Dock = DockStyle.Fill, .PanelName = "Project"}
            aGridControlexp.KeyFieldName = "KeyID"
            aGridControlexp.ParentFieldName = "ParentID"
            newForm.Controls.Add(aGridControlexp)
            newForm.MdiParent = Me
            newForm.Show()
            Me.Cursor = Cursors.Default
        Else
            If MessageWindow.ShowMessage(DeskTopManager.GetMessage("MES-000001")) = DialogResult.OK Then
                LoadLoginForm()
            End If
        End If
    End Sub

    ''' <summary>
    ''' FRM_00038 (LotBusinessFlow)
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00038_FRM_00038_LotBusinessFlow(ByVal sender As System.Object, ByVal e As NavBarLinkEventArgs) Handles MNU_00038.LinkClicked
        aMDIHelper.MNU_FRM_LoadGrid("FRM_00038", e.Link.Caption, e.Link.GetImage(), PLTypeOf.LotBusinessFlow_PL, "LotBusFlow")
    End Sub


    ''' <summary>
    ''' FRM_00016_Product
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00036_FRM_00016_Product(ByVal sender As System.Object, ByVal e As NavBarLinkEventArgs) Handles ProdExplorerNavBar.LinkClicked, MNU_00036.LinkClicked

        aMDIHelper.MNU_FRM_LoadExplorer("FRM_00016", e.Link.Caption, e.Link.GetImage, PLTypeOf.Product_PL, WinCtrlTypeOf.ProductExplorer, "ProductRoot")


    End Sub

#End Region '  " Production "

#Region "Configuration"

    ''' <summary>
    '''  GPMN_00003-ConFiguration  MNU_00103-ConfigurationReport   FRM_00075-ConfigurationReportForm 
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    ''' 
    Private Sub MNU_00103_LinkClicked(sender As Object, e As NavBarLinkEventArgs) Handles MNU_00103.LinkClicked
        Const frmName As String = "FRM_00075"
        Dim adockpanel As XtraBars.Docking.DockPanel
        Dim aModule As ReportExplorer

        If SCIEF.ActiveFramework.CommonExt.Base.AppManager.IsConnected Then
            Me.Cursor = Cursors.WaitCursor

            If Not FormIsOpen(frmName) Then
                adockpanel = DockManager1.AddPanel(XtraBars.Docking.DockingStyle.Left)
                '
                'OUTSTANDINGISSUE: ramener le GroupMenu dans le constructeur au lieu de devoir se souvenir quil faut setter le Group. clieng 2013-04-19.
                aModule = New ReportExplorer("ReportRoot_MNU_00103") With {.Dock = DockStyle.Fill, .PL = Nothing, .PanelName = frmName, .GroupMenuID = IdRepository.GroupMenu.Item("GPMN_00003"), .Icon = e.Link.GetImage}
                '
                adockpanel.FloatVertical = True
                adockpanel.Name = frmName
                adockpanel.Text = e.Link.Caption
                adockpanel.Width = 450
                adockpanel.Visibility = XtraBars.Docking.DockVisibility.Visible
                adockpanel.ControlContainer.Controls.Add(aModule)

                Dim DockImage As Image = CType(e.Link.GetImage().Clone, Image)
                DockImage.RotateFlip(RotateFlipType.Rotate270FlipNone)
                adockpanel.Image = DockImage

            Else
                If DockManager1.Panels(frmName).Visibility = XtraBars.Docking.DockVisibility.Hidden Then
                    DockManager1.Panels(frmName).Visibility = XtraBars.Docking.DockVisibility.AutoHide
                End If
            End If

            Me.Cursor = Cursors.Default
        Else
            '"Please Connect to a Database"
            If MessageWindow.ShowMessage(DeskTopManager.GetMessage("MES-000001")) = DialogResult.OK Then
                LoadLoginForm()
            End If
        End If
    End Sub


    ''' <summary>
    ''' MNU_00113_FRM_00084_SOP
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00113_FRM_00084_SOP(sender As Object, e As NavBarLinkEventArgs) Handles MNU_00113.LinkClicked
        aMDIHelper.MNU_FRM_LoadExplorer("FRM_00084", e.Link.Caption, e.Link.GetImage, PLTypeOf.SOP_PL, WinCtrlTypeOf.SOPExplorer, "SOPRoot")
    End Sub

    ''' <summary>
    ''' FRM_00049 (Operation)
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00076_LinkClicked(sender As System.Object, e As DevExpress.XtraNavBar.NavBarLinkEventArgs) Handles MNU_00076.LinkClicked
        ' aMDIHelper.MNU_FRM_LoadGrid("FRM_00049", e.Link.Caption, e.Link.GetImage(), PLTypeOf.Operation_PL, "Operation")


        Const frmName As String = "FRM_00049"

        If SCIEF.ActiveFramework.CommonExt.Base.AppManager.IsConnected Then
            Me.Cursor = Cursors.WaitCursor

            'J'ai tu le droit a cette fonction/Form
            If Not FormIsOpen(frmName) Then

                Dim aGridExt As GridExtPL = New GridExtPL() With {.Dock = DockStyle.Fill, .Pl = New SystemBoxSDK.PL.MESSDK.Operation_PL("Operation"), .SecureGrid = True}
                Dim newForm As XtraEditors.XtraForm = New XtraEditors.XtraForm() With {.Name = frmName, .Text = e.Link.Caption, .Icon = ImageExt.ToIcon(e.Link.GetImage(), 16, True), .ShowIcon = True}

                AddHandler aGridExt.InitNewMasterRow, AddressOf Operation_InitNewMasterRow
                AddHandler newForm.FormClosing, AddressOf MDIForm_Closing
                newForm.Controls.Add(aGridExt)
                newForm.MdiParent = Me
                newForm.Show()

            End If

            Me.Cursor = Cursors.Default
        Else
            If MessageWindow.ShowMessage(DeskTopManager.GetMessage("MES-000001")) = DialogResult.OK Then
                LoadLoginForm()
            End If
        End If
    End Sub

    Private Sub Operation_InitNewMasterRow(ByVal sender As Object, ByVal e As InitNewRowEventArgs)
        Dim view As GridView = CType(sender, GridView)
        Dim row As DataRow = view.GetFocusedDataRow()
        row("OperationId") = Guid.NewGuid
        row("EnergieCost") = 0
        row("DirectLaborCost") = 0
        row("OvhCost") = 0
    End Sub


    ''' <summary>
    ''' FRM_00018_Test
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00039_FRM_00018_Test(sender As System.Object, e As NavBarLinkEventArgs) Handles MNU_00039.LinkClicked
        aMDIHelper.MNU_FRM_LoadGrid("FRM_00018", e.Link.Caption, e.Link.GetImage(), PLTypeOf.Test_PL, "Test")
    End Sub


    ''' <summary>
    ''' FRM_00017_Specification
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00017_LinkClicked_FRM_00017_Specification(sender As System.Object, e As NavBarLinkEventArgs) Handles MNU_00017.LinkClicked

        aMDIHelper.MNU_FRM_LoadExplorer("FRM_00017", e.Link.Caption, e.Link.GetImage(), PLTypeOf.Specification_PL, WinCtrlTypeOf.SpecificationExplorer, "SpecificationRoot")

    End Sub

    ''' <summary>
    ''' FRM_00007 (ItemMaster)
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00040_LinkClicked_FRM_00007_ItemMaster(sender As System.Object, e As NavBarLinkEventArgs) Handles MNU_00040.LinkClicked

        aMDIHelper.MNU_FRM_LoadExplorer("FRM_00007", e.Link.Caption, e.Link.GetImage(), PLTypeOf.ItemMaster_PL, WinCtrlTypeOf.ItemMasterExplorer, "ItemMasterRoot")

    End Sub

#End Region ' "Configuration"

#Region "Quality "

    ''' <summary>
    ''' GPMN_00009-Quality   MNU_00094-QualityReport   FRM_00064-QualityReportForm
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00094_LinkClicked(sender As Object, e As NavBarLinkEventArgs) Handles MNU_00094.LinkClicked
        Const frmName As String = "FRM_00064"
        Dim adockpanel As XtraBars.Docking.DockPanel
        Dim aModule As ReportExplorer

        If SCIEF.ActiveFramework.CommonExt.Base.AppManager.IsConnected Then
            Me.Cursor = Cursors.WaitCursor

            If Not FormIsOpen(frmName) Then
                adockpanel = DockManager1.AddPanel(XtraBars.Docking.DockingStyle.Left)
                '
                aModule = New ReportExplorer("ReportRoot_MNU_00094", True) With {.Dock = DockStyle.Fill, .PL = Nothing, .PanelName = frmName, .GroupMenuID = IdRepository.GroupMenu.Item("GPMN_00009")}
                '
                adockpanel.FloatVertical = True
                adockpanel.Name = frmName
                adockpanel.Text = e.Link.Caption
                adockpanel.Width = 500
                adockpanel.Visibility = XtraBars.Docking.DockVisibility.Visible
                adockpanel.ControlContainer.Controls.Add(aModule)

                Dim DockImage As Image = CType(e.Link.GetImage().Clone, Image)
                DockImage.RotateFlip(RotateFlipType.Rotate270FlipNone)
                adockpanel.Image = DockImage

            Else
                If DockManager1.Panels(frmName).Visibility = XtraBars.Docking.DockVisibility.Hidden Then
                    DockManager1.Panels(frmName).Visibility = XtraBars.Docking.DockVisibility.AutoHide
                End If
            End If

            Me.Cursor = Cursors.Default
        Else
            '"Please Connect to a Database"
            If MessageWindow.ShowMessage(DeskTopManager.GetMessage("MES-000001")) = DialogResult.OK Then
                LoadLoginForm()
            End If
        End If
    End Sub

    ''' <summary>
    ''' FRM_00041_LotQualityGrade
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00010_FRM_00041_LotQualityGrade(ByVal sender As System.Object, ByVal e As NavBarLinkEventArgs) Handles MNU_00010.LinkClicked
        Dim frmName As String = "FRM_00041"
        If SCIEF.ActiveFramework.CommonExt.Base.AppManager.IsConnected Then
            Me.Cursor = Cursors.WaitCursor
            Dim newForm As XtraEditors.XtraForm = New XtraEditors.XtraForm() With {.Text = e.Link.Caption, .Name = frmName, .Icon = ImageExt.ToIcon(e.Link.GetImage(), 16, True), .ShowIcon = True}
            Dim aPL As SystemBoxSDK.PL.Void_PL = New SystemBoxSDK.PL.Void_PL("LotQualityGrade")
            Dim x As GridExtPL = New GridExtPL() With {.Dock = DockStyle.Fill, .Pl = aPL, .FormCtrlCD = frmName}
            x.SecureGrid = True
            newForm.Controls.Add(x)
            newForm.MdiParent = Me
            newForm.Show()
            Me.Cursor = Cursors.Default
        Else
            If MessageWindow.ShowMessage(DeskTopManager.GetMessage("MES-000001")) = DialogResult.OK Then
                LoadLoginForm()
            End If
        End If
    End Sub


    ''' <summary>
    ''' FRM_00020 (Sample)
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00012_LinkClicked(sender As System.Object, e As NavBarLinkEventArgs) Handles MNU_00012.LinkClicked
        Const frmName As String = "FRM_00020"
        Dim aSampleHeader As PLBase
        Dim aModule As DevExpress.XtraEditors.XtraUserControl

        If SCIEF.ActiveFramework.CommonExt.Base.AppManager.IsConnected Then
            Me.Cursor = Cursors.WaitCursor

            Dim adockpanel As XtraBars.Docking.DockPanel = DockManager1.AddPanel(XtraBars.Docking.DockingStyle.Left)
            adockpanel.FloatVertical = True
            adockpanel.Name = frmName
            adockpanel.Text = e.Link.Caption
            adockpanel.Width = 500


            Dim DockImage As Image = CType(e.Link.GetImage().Clone, Image)
            DockImage.RotateFlip(RotateFlipType.Rotate270FlipNone)
            adockpanel.Image = DockImage


            adockpanel.Visibility = XtraBars.Docking.DockVisibility.AutoHide

            Dim aGridaGridControlExp As SystemBoxWinSDK.SampleExplorer

            aSampleHeader = PLBase.CreateInstanceOf(PLTypeOf.SampleHeader_PL, "SampleHeaderRoot")
            aModule = WinCtrlBase.CreateInstanceOf(WinCtrlTypeOf.SampleExplorer)
            aGridaGridControlExp = TryCast(aModule, SampleExplorer)

            aGridaGridControlExp.ArchiveField = "QAQCInspLot.StatusID_FK"
            aGridaGridControlExp.ArchiveId = New System.Guid("1A7FA64A-2603-4EC1-AF78-E7098AAEE05F")
            aGridaGridControlExp.ArchiveIncluded = False

            aGridaGridControlExp.QueryName = "SampleHeaderRoot"
            aGridaGridControlExp.PL = aSampleHeader
            aGridaGridControlExp.PanelName = frmName
            aGridaGridControlExp.Dock = DockStyle.Fill
            aGridaGridControlExp.KeyFieldName = "KeyID"
            aGridaGridControlExp.ParentFieldName = "ParentID"

            adockpanel.ControlContainer.Controls.Add(aGridaGridControlExp)

            Dim newForm As XtraEditors.XtraForm = New XtraEditors.XtraForm() With {.Name = frmName, .Text = e.Link.Caption, .Icon = ImageExt.ToIcon(e.Link.GetImage(), 16, True), .ShowIcon = True}
            AddHandler newForm.FormClosing, AddressOf MDIForm_Closing
            newForm.MdiParent = Me

            Me.Cursor = Cursors.Default
        Else
            If MessageWindow.ShowMessage(DeskTopManager.GetMessage("MES-000001")) = DialogResult.OK Then
                LoadLoginForm()
            End If
        End If
    End Sub

    ''' <summary>
    ''' FRM_00019 (Sample Result)
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00002_LinkClicked(sender As System.Object, e As NavBarLinkEventArgs) Handles MNU_00002.LinkClicked
        Const frmName As String = "FRM_00019"
        If SCIEF.ActiveFramework.CommonExt.Base.AppManager.IsConnected Then
            Me.Cursor = Cursors.WaitCursor
            If Not FormIsOpen(frmName) Then
                Dim frm As ResultsEntryForm = New ResultsEntryForm() With {.MdiParent = Me, .Text = e.Link.Caption, .Name = frmName}
                frm.Show()
            End If
            Me.Cursor = Cursors.Default
        Else
            If MessageWindow.ShowMessage(DeskTopManager.GetMessage("MES-000001")) = DialogResult.OK Then
                LoadLoginForm()
            End If
        End If
    End Sub


    ''' <summary>
    ''' FRM_????? (COA)
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00041_LinkClicked(sender As System.Object, e As NavBarLinkEventArgs) Handles MNU_00041.LinkClicked
        If SCIEF.ActiveFramework.CommonExt.Base.AppManager.IsConnected Then
            'Dim aCOAWizard As COAWizardExt = New COAWizardExt
            'aCOAWizard.Show()

            Dim aWizard As PurgeTableWizardExt = New PurgeTableWizardExt
            aWizard.Show()
        Else
            If MessageWindow.ShowMessage(DeskTopManager.GetMessage("MES-000001")) = DialogResult.OK Then
                LoadLoginForm()
            End If
        End If
    End Sub

    ''' <summary>
    ''' FRM_00040 (COAResult)
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00042_LinkClicked(sender As System.Object, e As NavBarLinkEventArgs) Handles MNU_00042.LinkClicked
        Const frmName As String = "CertificateOfAnalysis"
        If SCIEF.ActiveFramework.CommonExt.Base.AppManager.IsConnected Then
            Me.Cursor = Cursors.WaitCursor
            If Not FormIsOpen(frmName) Then

                Dim newForm As XtraEditors.XtraForm = New XtraEditors.XtraForm() With {.Name = frmName, .Text = e.Link.Caption, .Icon = ImageExt.ToIcon(e.Link.GetImage(), 16, True), .ShowIcon = True}
                Dim pl As SystemBoxSDK.PL.MESSDK.CertificateOfAnalysis_PL = New SystemBoxSDK.PL.MESSDK.CertificateOfAnalysis_PL("CertificateOfAnalysis")
                Dim aGridControl As GridExtPL = New GridExtPL() With {.Dock = DockStyle.Fill, .Pl = pl, .SecureGrid = True}

                AddHandler aGridControl.MainContextMenuBeforePopup, AddressOf COAResultWizard.COA_MainContextMenuBeforePopup
                AddHandler aGridControl.MasterCustomRowCellEditForEditing, AddressOf COAResultWizard.MasterCustomRowCellEditForEditing
                AddHandler aGridControl.ShownMasterEditor, AddressOf COAResultWizard.COA_ShownMasterEditor


                aGridControl.GridActionOptionList.Add(New ActionOption("COA", "ACT_00008", "Print COA", AddressOf COAResultWizard.PrintCOA, True, True)) 'Print Current COA
                aGridControl.GridActionOptionList.Add(New ActionOption("COA", "PreviewCOA", "View in PDF", AddressOf COAResultWizard.PreviewCOA, True, True)) ' View in PDF
                aGridControl.GridActionOptionList.Add(New ActionOption("COA", "ACT_00201", "Open inDesigner", AddressOf COAResultWizard.ShowInDesigner, True, True)) ' View in PDF
                newForm.Controls.Add(aGridControl)
                newForm.MdiParent = Me

            End If

            Me.Cursor = Cursors.Default
        Else
            If MessageWindow.ShowMessage(DeskTopManager.GetMessage("MES-000001")) = DialogResult.OK Then
                LoadLoginForm()
            End If
        End If
    End Sub

    ''' <summary>
    ''' FRM_????? (QCRelease)
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00072_LinkClicked(sender As System.Object, e As DevExpress.XtraNavBar.NavBarLinkEventArgs) Handles MNU_00072.LinkClicked
        If SCIEF.ActiveFramework.CommonExt.Base.AppManager.IsConnected Then
            Me.Cursor = Cursors.WaitCursor
            Dim aModule As DevExpress.XtraEditors.XtraUserControl
            Dim chgsts As SystemBoxWinSDK.ChangeStatusControl
            aModule = SystemBoxWinSDK.Win.WinCtrlBase.CreateInstanceOf(WinCtrlTypeOf.ChangeStatusControl)
            chgsts = CType(aModule, ChangeStatusControl)
            chgsts.QueryName = "ChangeLotStatus"
            chgsts.Dock = DockStyle.Fill
            Dim newForm As XtraEditors.XtraForm = New XtraEditors.XtraForm() With {.Text = e.Link.Caption, .Icon = ImageExt.ToIcon(e.Link.GetImage(), 16, True), .ShowIcon = True}
            newForm.Controls.Add(chgsts)
            newForm.MdiParent = Me
            Me.Cursor = Cursors.Default
        Else
            If MessageWindow.ShowMessage(DeskTopManager.GetMessage("MES-000001")) = DialogResult.OK Then
                LoadLoginForm()
            End If
        End If
    End Sub
    ''' <summary>
    ''' FRM_????? (Change Lot Status)
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00074_LinkClicked(sender As System.Object, e As DevExpress.XtraNavBar.NavBarLinkEventArgs) Handles MNU_00074.LinkClicked
        If SCIEF.ActiveFramework.CommonExt.Base.AppManager.IsConnected Then
            Me.Cursor = Cursors.WaitCursor
            Dim aModule As DevExpress.XtraEditors.XtraUserControl
            Dim chgsts As ChangeStatusControl
            aModule = SystemBoxWinSDK.Win.WinCtrlBase.CreateInstanceOf(WinCtrlTypeOf.ChangeStatusControl)
            chgsts = TryCast(aModule, ChangeStatusControl)
            chgsts.QueryName = "ChangeLotStatus"
            chgsts.Dock = DockStyle.Fill
            Dim newForm As XtraEditors.XtraForm = New XtraEditors.XtraForm() With {.Text = e.Link.Caption, .Icon = ImageExt.ToIcon(e.Link.GetImage(), 16, True), .ShowIcon = True}
            newForm.Controls.Add(chgsts)
            newForm.MdiParent = Me
            Me.Cursor = Cursors.Default
        Else
            If MessageWindow.ShowMessage(DeskTopManager.GetMessage("MES-000001")) = DialogResult.OK Then
                LoadLoginForm()
            End If
        End If
    End Sub

    ''' <summary>
    ''' FRM_????? (ReTest)
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00075_LinkClicked(sender As System.Object, e As DevExpress.XtraNavBar.NavBarLinkEventArgs) Handles MNU_00075.LinkClicked
        If SCIEF.ActiveFramework.CommonExt.Base.AppManager.IsConnected Then
            Me.Cursor = Cursors.WaitCursor

            Dim aWizard As RetestWizardExt = New RetestWizardExt
            aWizard.Show()

            Me.Cursor = Cursors.Default
        Else
            If MessageWindow.ShowMessage(DeskTopManager.GetMessage("MES-000001")) = DialogResult.OK Then
                LoadLoginForm()
            End If
        End If

    End Sub


    ''' <summary>
    ''' FRM_00059 (Etiquette)
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00085_LinkClicked(sender As System.Object, e As DevExpress.XtraNavBar.NavBarLinkEventArgs) Handles MNU_00085.LinkClicked
        'Const frmName As String = "FRM_00059"  'Not use for now. clieng 2012-05-24
        Dim aDiagResult As Windows.Forms.DialogResult
        If SCIEF.ActiveFramework.CommonExt.Base.AppManager.IsConnected Then

            Dim queryName As String = "EtiquetteAllergene"
            Dim reportName As String = "EssaiEtiquetteAllergene"

            'This form is for requesting parameters : Sequence No & Nb of Copies
            Dim frm As SCIEF.ActiveFramework.WinFormExt.Etiquette = New SCIEF.ActiveFramework.WinFormExt.Etiquette()

            aDiagResult = frm.ShowDialog()
            If aDiagResult = Windows.Forms.DialogResult.OK Then
                Me.Cursor = Cursors.WaitCursor
                If Not String.IsNullOrWhiteSpace(frm.NoSequence) Then
                    Using mquery As MetaQuery = MetaQuery.GetMetaQueryByName(queryName)
                        If mquery IsNot Nothing Then
                            Using report As XtraReports.UI.XtraReport = SCIEF.ActiveFramework.CommonExt.RptNotification.GetReportFromDB(reportName)
                                If report IsNot Nothing Then
                                    Dim ps As New DevExpress.XtraPrinting.PrintingSystemBase()

                                    mquery.SQLWhere = mquery.SQLWhere + String.Format("LotCD = '{0}'", frm.NoSequence)
                                    mquery.FillResultQuery()
                                    report.DataSource = mquery.ResultQuery

                                    For i As Integer = 0 To frm.NbCopie - 1
                                        report.CreateDocument()
                                        ps.Pages.AddRange(report.PrintingSystem.Pages)
                                    Next i
                                    Dim aFrm As ReportPrintForm = New SCIEF.ActiveFramework.WinFormExt.ReportPrintForm() With {.MdiParent = Me.MdiParent, .Text = "Print Label", .RptPrintingSystem = ps}
                                    aFrm.Show()
                                Else
                                    MessageWindow.ShowMessage(String.Format("{0}, Not Found in Report Definition. Report abord", reportName), MsgBoxStyle.Information)
                                End If
                            End Using
                        Else
                            MessageWindow.ShowMessage(String.Format("{0}, Not Found in MetaCommand. Report abord", queryName), MsgBoxStyle.Information)
                        End If
                    End Using
                Else
                    MessageWindow.ShowMessage("Please Enter a Lot Sequence", MsgBoxStyle.Information)
                End If
                Me.Cursor = Cursors.Default
            End If
        Else
            If MessageWindow.ShowMessage(DeskTopManager.GetMessage("MES-000001")) = DialogResult.OK Then
                LoadLoginForm()
            End If
        End If
    End Sub


#End Region ' "Quality "

#Region "Maintenance"

    ''' <summary>
    ''' GPMN_00015-Maintenance	MNU_00108-MaintenanceReport  FRM_00080-MaintenanceReportForm
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00108_LinkPressed(sender As Object, e As NavBarLinkEventArgs) Handles MNU_00108.LinkPressed
        Const frmName As String = "FRM_00080"
        Dim adockpanel As XtraBars.Docking.DockPanel
        Dim aModule As ReportExplorer

        If SCIEF.ActiveFramework.CommonExt.Base.AppManager.IsConnected Then
            Me.Cursor = Cursors.WaitCursor

            If Not FormIsOpen(frmName) Then
                adockpanel = DockManager1.AddPanel(XtraBars.Docking.DockingStyle.Left)
                '
                'OUTSTANDINGISSUE: ramener le GroupMenu dans le constructeur au lieu de devoir se souvenir quil faut setter le Group. clieng 2013-04-19.
                aModule = New ReportExplorer("ReportRoot_MNU_00108") With {.Dock = DockStyle.Fill, .PL = Nothing, .PanelName = frmName, .GroupMenuID = IdRepository.GroupMenu.Item("GPMN_00015")}
                '
                adockpanel.FloatVertical = True
                adockpanel.Name = frmName
                adockpanel.Text = e.Link.Caption
                adockpanel.Width = 450
                adockpanel.Visibility = XtraBars.Docking.DockVisibility.Visible
                adockpanel.ControlContainer.Controls.Add(aModule)

                Dim DockImage As Image = CType(e.Link.GetImage().Clone, Image)
                DockImage.RotateFlip(RotateFlipType.Rotate270FlipNone)
                adockpanel.Image = DockImage

            Else
                If DockManager1.Panels(frmName).Visibility = XtraBars.Docking.DockVisibility.Hidden Then
                    DockManager1.Panels(frmName).Visibility = XtraBars.Docking.DockVisibility.AutoHide
                End If
            End If

            Me.Cursor = Cursors.Default
        Else
            '"Please Connect to a Database"
            If MessageWindow.ShowMessage(DeskTopManager.GetMessage("MES-000001")) = DialogResult.OK Then
                LoadLoginForm()
            End If
        End If
    End Sub

    ''' <summary>
    ''' FRM_00033 (EquipmentType)
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00057_LinkClicked(ByVal sender As System.Object, ByVal e As NavBarLinkEventArgs) Handles MNU_00057.LinkClicked
        Const frmName As String = "FRM_00033"

        If SCIEF.ActiveFramework.CommonExt.Base.AppManager.IsConnected Then
            Me.Cursor = Cursors.WaitCursor
            Dim newForm As XtraEditors.XtraForm = New XtraEditors.XtraForm() With {.Text = e.Link.Caption, .Icon = ImageExt.ToIcon(e.Link.GetImage(), 16, True), .ShowIcon = True}
            Dim aPL As SystemBoxSDK.PL.Void_PL = New SystemBoxSDK.PL.Void_PL("EquipmentTypes")

            Dim x As GridExtPL = New GridExtPL() With {.Dock = DockStyle.Fill, .Pl = aPL, .FormCtrlCD = frmName}
            newForm.Controls.Add(x)
            newForm.MdiParent = Me
            newForm.Show()

            Me.Cursor = Cursors.Default
        Else
            If MessageWindow.ShowMessage(DeskTopManager.GetMessage("MES-000001")) = DialogResult.OK Then
                LoadLoginForm()
            End If
        End If
    End Sub


    ''' <summary>
    ''' FRM_00032 (Equipment)
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00056_FRM_00032_Equipment(sender As System.Object, e As NavBarLinkEventArgs) Handles MNU_00056.LinkClicked
        aMDIHelper.MNU_FRM_LoadExplorer("FRM_00032", e.Link.Caption, e.Link.GetImage, PLTypeOf.Equipment_PL, WinCtrlTypeOf.EquipmentExplorer, "EquipmentTreeRoot")
        '  aGridControl.GridActionOptionList.Add(New ActionOption("XXXXX", "XXXXXXXX", "Save to Product", AddressOf Equipment_SaveToPrduct, True, True))
    End Sub

    ''' <summary>
    ''' FRM_00047 (WorkCenter)
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00052_LinkClicked(sender As System.Object, e As NavBarLinkEventArgs) Handles MNU_00052.LinkClicked
        aMDIHelper.MNU_FRM_LoadGrid("FRM_00047", e.Link.Caption, e.Link.GetImage(), PLTypeOf.WorkCenter_PL, "WorkCenter")
    End Sub

#End Region ' "Maintenance"

#Region "Shared Info"

    ''' <summary>
    ''' FRM_00046 (Units)
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00049_LinkClicked(ByVal sender As System.Object, ByVal e As NavBarLinkEventArgs) Handles MNU_00049.LinkClicked

        aMDIHelper.MNU_FRM_LoadExplorer("FRM_00046", e.Link.Caption, e.Link.GetImage, PLTypeOf.Units_PL, WinCtrlTypeOf.UnitExplorer, "UnitRoot")

    End Sub

    ''' <summary>
    ''' FRM_00044_Currencies
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00050_FRM_00044_Currencies(ByVal sender As System.Object, ByVal e As NavBarLinkEventArgs) Handles MNU_00050.LinkClicked
        aMDIHelper.MNU_FRM_LoadGrid("FRM_00046", e.Link.Caption, e.Link.GetImage(), PLTypeOf.Currencies_PL, "Currencies")

    End Sub

    ''' <summary>
    ''' FRM_00029_SocietyInfo
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00043_FRM_00029_SocietyInfo(ByVal sender As System.Object, ByVal e As NavBarLinkEventArgs) Handles MNU_00043.LinkClicked
        aMDIHelper.MNU_FRM_LoadGrid("FRM_00029", e.Link.Caption, e.Link.GetImage(), PLTypeOf.Void_PL, "CompanyInfo")

    End Sub


    ''' <summary>
    ''' FRM_00048 (WorkCode)
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00051_LinkClicked(ByVal sender As System.Object, ByVal e As NavBarLinkEventArgs) Handles MNU_00051.LinkClicked
        aMDIHelper.MNU_FRM_LoadGrid("FRM_00048", e.Link.Caption, e.Link.GetImage(), PLTypeOf.WorkCode_PL, "WorkCode")

    End Sub

    ''' <summary>
    ''' GPMN_00014-Public	MNU_00109-PublicReport   FRM_00081-MaintenanceReportForm
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00109_LinkPressed(sender As Object, e As NavBarLinkEventArgs) Handles MNU_00109.LinkPressed
        Const frmName As String = "FRM_00081"
        Dim adockpanel As XtraBars.Docking.DockPanel
        Dim aModule As ReportExplorer

        If SCIEF.ActiveFramework.CommonExt.Base.AppManager.IsConnected Then
            Me.Cursor = Cursors.WaitCursor

            If Not FormIsOpen(frmName) Then
                adockpanel = DockManager1.AddPanel(XtraBars.Docking.DockingStyle.Left)
                '
                'OUTSTANDINGISSUE: ramener le GroupMenu dans le constructeur au lieu de devoir se souvenir quil faut setter le Group. clieng 2013-04-19.
                aModule = New ReportExplorer("ReportRoot_MNU_00109") With {.Dock = DockStyle.Fill, .PL = Nothing, .PanelName = frmName, .GroupMenuID = IdRepository.GroupMenu.Item("GPMN_00014")}
                '
                adockpanel.FloatVertical = True
                adockpanel.Name = frmName
                adockpanel.Text = e.Link.Caption
                adockpanel.Width = 450
                adockpanel.Visibility = XtraBars.Docking.DockVisibility.Visible
                adockpanel.ControlContainer.Controls.Add(aModule)

                Dim DockImage As Image = CType(e.Link.GetImage().Clone, Image)
                DockImage.RotateFlip(RotateFlipType.Rotate270FlipNone)
                adockpanel.Image = DockImage

            Else
                If DockManager1.Panels(frmName).Visibility = XtraBars.Docking.DockVisibility.Hidden Then
                    DockManager1.Panels(frmName).Visibility = XtraBars.Docking.DockVisibility.AutoHide
                End If
            End If

            Me.Cursor = Cursors.Default
        Else
            '"Please Connect to a Database"
            If MessageWindow.ShowMessage(DeskTopManager.GetMessage("MES-000001")) = DialogResult.OK Then
                LoadLoginForm()
            End If
        End If
    End Sub

#End Region ' "Shared Info"

#Region " RH "

    ''' <summary>
    ''' GPMN_00011-RH	MNU_00107-HRReport  FRM_00079-HRReportForm
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00107_LinkPressed(sender As Object, e As NavBarLinkEventArgs) Handles MNU_00107.LinkPressed
        Const frmName As String = "FRM_00079"
        Dim adockpanel As XtraBars.Docking.DockPanel
        Dim aModule As ReportExplorer

        If SCIEF.ActiveFramework.CommonExt.Base.AppManager.IsConnected Then
            Me.Cursor = Cursors.WaitCursor

            If Not FormIsOpen(frmName) Then
                adockpanel = DockManager1.AddPanel(XtraBars.Docking.DockingStyle.Left)
                '
                'OUTSTANDINGISSUE: ramener le GroupMenu dans le constructeur au lieu de devoir se souvenir quil faut setter le Group. clieng 2013-04-19.
                aModule = New ReportExplorer("ReportRoot_MNU_00107") With {.Dock = DockStyle.Fill, .PL = Nothing, .PanelName = frmName, .GroupMenuID = IdRepository.GroupMenu.Item("GPMN_00011")}
                '
                adockpanel.FloatVertical = True
                adockpanel.Name = frmName
                adockpanel.Text = e.Link.Caption
                adockpanel.Width = 450
                adockpanel.Visibility = XtraBars.Docking.DockVisibility.Visible
                adockpanel.ControlContainer.Controls.Add(aModule)

                Dim DockImage As Image = CType(e.Link.GetImage().Clone, Image)
                DockImage.RotateFlip(RotateFlipType.Rotate270FlipNone)
                adockpanel.Image = DockImage

            Else
                If DockManager1.Panels(frmName).Visibility = XtraBars.Docking.DockVisibility.Hidden Then
                    DockManager1.Panels(frmName).Visibility = XtraBars.Docking.DockVisibility.AutoHide
                End If
            End If

            Me.Cursor = Cursors.Default
        Else
            '"Please Connect to a Database"
            If MessageWindow.ShowMessage(DeskTopManager.GetMessage("MES-000001")) = DialogResult.OK Then
                LoadLoginForm()
            End If
        End If
    End Sub


    ''' <summary>
    ''' FRM_00042 (Employees)
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00053_LinkClicked(ByVal sender As System.Object, ByVal e As NavBarLinkEventArgs) Handles MNU_00053.LinkClicked

        aMDIHelper.MNU_FRM_LoadExplorer("FRM_00042", e.Link.Caption, e.Link.GetImage, PLTypeOf.Employee_PL, WinCtrlTypeOf.EmployeeExplorer, "EmployeeTreeRoot")

    End Sub
    '

#End Region '" RH "

#Region "IE"


    ''' <summary>
    ''' GPMN_00005-GO IE	MNU_00110-GOReport   FRM_00082-GOReportForm
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00110_LinkPressed(sender As Object, e As NavBarLinkEventArgs) Handles MNU_00110.LinkPressed
        Const frmName As String = "FRM_00082"
        Dim adockpanel As XtraBars.Docking.DockPanel
        Dim aModule As ReportExplorer

        If SCIEF.ActiveFramework.CommonExt.Base.AppManager.IsConnected Then
            Me.Cursor = Cursors.WaitCursor

            If Not FormIsOpen(frmName) Then
                adockpanel = DockManager1.AddPanel(XtraBars.Docking.DockingStyle.Left)
                '
                'OUTSTANDINGISSUE: ramener le GroupMenu dans le constructeur au lieu de devoir se souvenir quil faut setter le Group. clieng 2013-04-19.
                aModule = New ReportExplorer("ReportRoot_MNU_00110") With {.Dock = DockStyle.Fill, .PL = Nothing, .PanelName = frmName, .GroupMenuID = IdRepository.GroupMenu.Item("GPMN_00005")}
                '
                adockpanel.FloatVertical = True
                adockpanel.Name = frmName
                adockpanel.Text = e.Link.Caption
                adockpanel.Width = 450
                adockpanel.Visibility = XtraBars.Docking.DockVisibility.Visible
                adockpanel.ControlContainer.Controls.Add(aModule)

                Dim DockImage As Image = CType(e.Link.GetImage().Clone, Image)
                DockImage.RotateFlip(RotateFlipType.Rotate270FlipNone)
                adockpanel.Image = DockImage

            Else
                If DockManager1.Panels(frmName).Visibility = XtraBars.Docking.DockVisibility.Hidden Then
                    DockManager1.Panels(frmName).Visibility = XtraBars.Docking.DockVisibility.AutoHide
                End If
            End If

            Me.Cursor = Cursors.Default
        Else
            '"Please Connect to a Database"
            If MessageWindow.ShowMessage(DeskTopManager.GetMessage("MES-000001")) = DialogResult.OK Then
                LoadLoginForm()
            End If
        End If
    End Sub


    ''' <summary>
    ''' FRM_00034 (Persons)
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MNU_00054_LinkClicked(ByVal sender As System.Object, ByVal e As NavBarLinkEventArgs) Handles MNU_00054.LinkClicked

        aMDIHelper.MNU_FRM_LoadExplorer("FRM_00030", e.Link.Caption, e.Link.GetImage, PLTypeOf.Persons_PL, WinCtrlTypeOf.PersonExplorer, "PersonRoot")
    End Sub

#End Region ' "IE"

#End Region ' NAVBar
End Class